필자는이 테스트를 위해 다음과 같은 객체에 대한 필자의 비교를 구축했다. 그것은 현재 서 있고 비교 된 필드 중 하나가 일치하지 않을 때 잘못된 값을 전달합니다. 비교를 실패한 필드에 대한 자세한 정보를 제공하는 방법이 있습니까?맞춤 비교의 실패에 대한 자세한 정보는 어떻게 얻을 수 있습니까?
[DataContract]
public class Stats : IEquatable<Stats>
{
[DataMember]
public string StatusCode { get; set; }
[DataMember]
public int ProspectCount { get; set; }
[DataMember]
public int MessageCount { get; set; }
[DataMember]
public int NewListingCount { get; set; }
[DataMember]
public int ReminderCount { get; set; }
[DataMember]
public int MyListingCount { get; set; }
[DataMember]
public int OfficeListingCount { get; set; }
public bool Equals(Stats other)
{
if (Object.ReferenceEquals(other, null)) return false;
if (Object.ReferenceEquals(this, other)) return true;
return StatusCode.Equals(other.StatusCode) &&
ProspectCount.Equals(other.ProspectCount) &&
MessageCount.Equals(other.MessageCount) &&
NewListingCount.Equals(other.NewListingCount) &&
ReminderCount.Equals(other.ReminderCount) &&
MyListingCount.Equals(other.MyListingCount) &&
OfficeListingCount.Equals(other.OfficeListingCount);
}
}
는 테스트 :
시험 이름 : GoodDataTests 테스트하면 FullName : ThunderBallApiTests.StatisticsTests.GoodDataTests 테스트 소스
는[Theory] [ExcelData("Stats.xls", "Select * from TestData")] public void GoodDataTests(int SubscriptionId, int ProfileId, int ClientID, string statusCode, int prospectCount, int messageCount, int newListingCount, int reminderCount, int myListingCount, int officListingCount) { DataContainers.Stats expectedStats = new DataContainers.Stats{ StatusCode = statusCode, ProspectCount = prospectCount, MessageCount = messageCount, NewListingCount = newListingCount, ReminderCount = reminderCount, MyListingCount = myListingCount, OfficeListingCount = officListingCount }; string url = Utils.CreateStatisticsUrlRequest(SubscriptionId,ProfileId,ClientID); string response = Utils.GetResponseBody(url); DataContainers.Stats results = JsonConvert.DeserializeObject<DataContainers.Stats>(response); Assert.Equal(expectedStats, results); }
xUnit의에서 나의 현재 오류 출력은 다음과 같은 : \ sky.dom \ mlfile1 \ users \ DanS \ 내 문서 \ Visual Studio 2012 \ Projects \ ThunderBallApiTests \ ThunderBallApiTests \ StatisticsTests.cs : 줄 20,테스트 결과 : 실패 시험 시간 : 0 : 00 : 20.203
결과 1 이름 : GoodDataTests (SubscriptionId : 167769, profileID가 : 1,571,394, 된 ClientID : 1234에 statusCode : "활성", prospectCount : 54, messageCount : 17 newListingCount : 0, reminderCount : 33, myListingCount : 0, officListingCount : 2) 결과 1의 결과 : 실패 결과 1 시간 : 0 : 00 : 01.471 결과 1 메시지 : 예상
Assert.Equal() 실패 : ThunderBallApiTests.DataContainers.Stats 실제 : ThunderBallApiTests.DataContainers.Stats 결과 1 StackTrace : ThunderBallApiTests.StatisticsTests.StatisticsGoodDataTests (Int32 SubscriptionId, Int3 2 SkyDevice \ ThunderBallApiTests \ IntelliSupportTests \ SkyDom \ MyFile \ 사용자 \ DanS \ My Documents \ Visual Studio 2012 \ Projects \ ThunderBallApiTests \ ThunderBallApiTests \ StatisticsTests.cs : line 36
좋은 물건. 감사. –