首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用于crm测试初始化问题的fakeXrmEasy

用于crm测试初始化问题的fakeXrmEasy
EN

Stack Overflow用户
提问于 2017-07-03 13:48:14
回答 1查看 1.2K关注 0票数 1

我试图遵循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

代码语言:javascript
复制
 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
            });

        }
    }


}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-07-03 14:34:50

您是否在CRM项目中使用早期绑定并获得正确的引用?如果您不使用早期绑定,您可以尝试延迟绑定。

代码语言:javascript
复制
//context.ProxyTypesAssembly = Assembly.GetAssembly(typeof(Account));

var account = new Entity();
account.LogicalName = "account";
account.Attributes["name"] = "your account name";
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44887233

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档