给定一个具有多个属性的对象,比如 System.Drawing.Rectangle,我想断言所有属性的值(当一个属性不匹配时不会停止)并报告所有属性。
我尝试了这段代码,希望它能做我想要的......
System.Drawing.Rectangle croppingRectangle = SomeMethodReturnsRectangle(testP1,testP2);
Assert.That(()=>{ croppingRectangle.X==testX && croppingRectangle.Y==testY },"expected X={0}, Y={1} but was X={2},Y={3}", testX,testY,croppingRectangle.X,croppingRectangle.Y);
NUnit 中执行此操作的正确方法是什么?
(我意识到这行得通:)
if(croppingRectangle.X==testX && croppingRectangle.Y==testY) {
Assert.Pass();
else
Assert.Fail("expected X={0}, Y={1} but was X={2},Y={3}", testX,testY,croppingRectangle.X,croppingRectangle.Y);