为什么会失败?
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了为什么会失败?相关的知识,希望对你有一定的参考价值。
“消息:声明。为真失败。预期:System.Collections.Generic.List1[...] but found System.Collections.Generic.List
1 [...]”
我不知道为什么会失败。有人可以帮助我解决此错误吗]
/// <summary> /// Test to Get the all the fee bands from Crm /// </summary> /// <returns>Response with a collection of ise_feeband entities</returns> [TestCategory("AnnualBillingService")] [TestMethod] public void GetFeeBandingListTest() List<ISE_feeband> fee_bands = new List<ISE_feeband>() ; //fee_bands.Add(new ISE_feeband()); string entityname = "entity name"; Guid ID = new Guid(); using (ShimsContext.Create()) //Arrange ShimCrmService.AllInstances.FetchString = ((@this, fetchXml) => return new Microsoft.Xrm.Sdk.EntityCollection() EntityName = entityname, MoreRecords = true, MinActiveRowVersion = "version", PagingCookie = "paging cookie", TotalRecordCount = 10, TotalRecordCountLimitExceeded = false, ; ); //Act var AnnualBillingService = new AnnualBillingService(); var response = AnnualBillingService.GetFeeBandingList(); //Assert Assert.IsNotNull(response, "Expected not-null response"); Assert.IsTrue(response.FeeBands == fee_bands, "Expected: " + fee_bands + " but found " + response.FeeBands); foreach (var FeeBands in fee_bands) Assert.IsTrue(FeeBands.Id == ID, "Expects True");
这里是代码。我无法理解该错误,奇怪的是,预期结果与实际结果相同,并且仍然出现错误。
“消息:Assert.IsTrue失败。预期:System.Collections.Generic.List1 [...]但找到System.Collections.Generic.List1 [...]”我不知道为什么会失败。谁能帮我解决这个错误...
答案
也许您正在寻找的是Collection的assert方法,用于比较类型的集合。 AreEqual
和AreEquivalent
之间有区别,我不太确定您的案子在这里,所以请看一看两者!
以上是关于为什么会失败?的主要内容,如果未能解决你的问题,请参考以下文章