public void EqualityTests() { var instance0 = new StubValueObject { StreetName = "One Microsoft Way", HouseNumber = 1, City = "Seattle" }; var instance1 = new StubValueObject { StreetName = "One Microsoft Way", HouseNumber = 1, City = "Seattle" }; var instance2 = new StubValueObject { StreetName = "One Microsoft Way", HouseNumber = 1, City = "New York" }; instance0.ShouldBe(instance1); instance1.ShouldBe(instance1); instance1.ShouldNotBe(instance2); }
public void EqualityTests() { var instance0 = new StubValueObject { StreetName = "One Microsoft Way", HouseNumber = 1, City = "Seattle" }; var instance1 = new StubValueObject { StreetName = "One Microsoft Way", HouseNumber = 1, City = "Seattle" }; var instance2 = new StubValueObject { StreetName = "One Microsoft Way", HouseNumber = 1, City = "New York" }; instance0.Equals(instance1).ShouldBeTrue(); //IEquatable (equals) instance0.ShouldBe(instance1); (instance0 == instance1).ShouldBeTrue(); // operator instance1.ShouldBe(instance1); #pragma warning disable CS1718 // Comparison made to same variable (instance1 == instance1).ShouldBeTrue(); // operator #pragma warning restore CS1718 // Comparison made to same variable instance1.ShouldNotBe(instance2); instance0.Equals(instance2).ShouldBeFalse(); // IEquatable }