我试图遵循FakeXrmEasy的基本教程,但我不知道为什么会出现错误。我安装了所有需要安装的东西来模拟Dynamic365,但是我仍然会遇到错误。我不知道我错过了什么,我真的想要能够使用这个工具。
CS1950集合初始化器的最佳重载添加方法‘List.Add(实体)’具有一些无效的参数-- unitTest c:\unitTest\acapell\documents\visual studio 2015\Projects\unitTest\unitTest\Program.cs 48 Active 无法找到类型或命名空间名称“CS0246”(您是缺少了使用指令还是程序集引用?)unitTest c:\Users\acapell\documents\visual studio 2015\Projects\unitTest\unitTest\Program.cs 45 Active
不知道我是否应该创建一个帐户类,我也尝试过,但这也不起作用。我得到了
CS1503参数1:无法从“unitTest.Account”转换为“Microsoft.Xrm.Sdk.Entity”unitTest c:\Users\acapell\documents\visual studio 2015\Projects\unitTest\unitTest\Program.cs 48 Active
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xunit;
using FakeItEasy;
using FakeXrmEasy;
using Microsoft.Xrm.Sdk;
namespace unitTest
{
class Program
{
static void Main(string[] args)
{
}
}
class unitTest
{
public object ProxyTypesAssembly { get; private set; }
public void MyFirstTest()
{//test method body
var context = new XrmFakedContext();
//You can think of a context like an Organisation database which stores entities In Memory.
//We can also use TypedEntities but we need to tell the context where to look for them,
//this could be done, easily, like this:
context.ProxyTypesAssembly = Assembly.GetAssembly(typeof(Account));
//We have to define our initial state now,
//by calling the Initialize method, which expects a list of entities.
var account = new Account() { Id = Guid.NewGuid(), Name = "My First Faked Account yeah!" };
context.Initialize(new List<Entity>() {
account
});
}
}
}发布于 2017-07-03 14:34:50
您是否在CRM项目中使用早期绑定并获得正确的引用?如果您不使用早期绑定,您可以尝试延迟绑定。
//context.ProxyTypesAssembly = Assembly.GetAssembly(typeof(Account));
var account = new Entity();
account.LogicalName = "account";
account.Attributes["name"] = "your account name";https://stackoverflow.com/questions/44887233
复制相似问题