두 System.Drawing.Size
구조 의 동등성을 주장하려고하는데 예상되는 주장 실패 대신 형식 예외가 발생합니다.
[TestMethod]
public void AssertStructs()
{
var struct1 = new Size(0, 0);
var struct2 = new Size(1, 1);
//This throws a format exception, "System.FormatException: Input string was not in a correct format."
Assert.AreEqual(struct1, struct2, "Failed. Expected {0}, actually it is {1}", struct1, struct2);
//This assert fails properly, "Failed. Expected {Width=0, Height=0}, actually it is {Width=1, Height=1}".
Assert.AreEqual(struct1, struct2, "Failed. Expected " + struct1 + ", actually it is " + struct2);
}
의도 된 동작입니까? 내가 여기서 뭔가 잘못하고 있니?
Assert.AreEqual(struct1, struct2, string.Format("Failed expected {0} actually is {1}
) (struct2.ToString를 struct1.ToString, ()))`?