"Message: Assert.Is True failed. Expected: System.Collections.Generic.List 1[...] but found System.Collections.Generic.List
1[...]"
I don't know why is it failing. Can anyone help me with this error please
/// <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");
}
}
}
Here is the code. I cannot understand the error, its strange that expected and actual result is the same and still getting error.
Maybe what you are looking for is Collection's assert methods, to compare collections of types. There is a difference between AreEqual
and AreEquivalent
and i am not pretty sure what your case is here, so take a look at them both!
Follow this link and you will find both methods and their documentation, it should help you enough. Clicky clicky
/// <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()
{
Guid ID = new Guid();
List<ISE_feeband> fee_bands = new List<ISE_feeband>();
using (ShimsContext.Create())
{
//Arrange
ShimCrmService.AllInstances.FetchString = ((@this, fetchXml) =>
{
var output = new Microsoft.Xrm.Sdk.EntityCollection()
{
EntityName = ISE_feeband.EntityLogicalName,
};
output.Entities.Add(new ISE_feeband()
{
Id = ID,
});
return output;
});
//Act
var AnnualBillingService = new AnnualBillingService();
var response = AnnualBillingService.GetFeeBandingList();
//Assert
Assert.IsNotNull(response, "Expected not-null response");
Assert.IsTrue(response.FeeBands.Count == 1, "Expected: " + fee_bands + " but found " + response.FeeBands);
foreach (var FeeBands in fee_bands)
{
Assert.IsTrue(FeeBands.ISE_feebandId == ID , "Expects True");
}
}
}
Problem solved guys THANK YOU all:)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.