2017-07-03 81 views
0

我想要遵循FakeXrmEasy的基本教程,但我不知道爲什麼我得到錯誤。我安裝了所有需要安裝的模擬動態365,但我仍然收到錯誤。我無法弄清楚我錯過了什麼,我真的希望能夠使用這個工具。fakeXrmEasy爲crm測試初始化​​問題

CS1950的最佳重載Add方法 'List.Add(實體)' 的集合初始化有單元測試C語言帶來的無效的參數:\用戶\ acapell \文件\的Visual Studio 2015年\項目\單元測試\單元測試\計劃。 cs 48 Active

CS0246無法找到類型或名稱空間名稱'Account'(缺少使用指令或程序集引用嗎?)unitTest c:\ Users \ acapell \ documents \ visual studio 2015 \ Projects \ unitTest \ unitTest \ Program.cs 45 Active

不知道我是否想創建一個帳戶類,我也試過t帽子,但也沒有工作。我

CS1503參數1:\用戶\ acapell \文件\的Visual Studio 2015年\項目\單元測試\單元測試\:無法從 'unitTest.Account' 到 'Microsoft.Xrm.Sdk.Entity' 單元測試Ç轉換Program.cs中48活動

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 
      }); 

     } 
    } 


} 

回答

2

你用你的CRM項目早期綁定,並獲得引用嗎?如果您不使用早期綁定,則可以嘗試後期綁定,例如

//context.ProxyTypesAssembly = Assembly.GetAssembly(typeof(Account)); 

var account = new Entity(); 
account.LogicalName = "account"; 
account.Attributes["name"] = "your account name"; 
+0

謝謝,我停止得到這些錯誤 – amberl

+0

你可以在github回購上發佈堆棧跟蹤嗎?它應該與早期和晚期工作,假設所有的參考都是好的:) – Jordi