Unit test equality is not domain equality
I came across a question on stackoverflow concerning comparing object for equality in unit test. The poster basically wants to get rid of series of assertions like this:
1 2 3 4 5 |
Assert.AreEqual(LeftObject.Property1, RightObject.Property1); Assert.AreEqual(LeftObject.Property2, RightObject.Property2); Assert.AreEqual(LeftObject.Property3, RightObject.Property3); ... Assert.AreEqual(LeftObject.PropertyN, RightObject.PropertyN); |
I agree, this is ugly. The more so if you have multiple tests that assert on the equality of these properties. You can always factor it […]