public void EqualsOperator_ShouldBeTrue_WhenBothObjectsAreNull() { StubValueObject a = null; StubValueObject b = null; (a == b).Should().BeTrue("both objects are null"); }
public void NotEqualsOperator_ShouldBeTrue_WhenValuesAreDifferent() { var compare = new StubValueObject("Mike", "Walsh"); (this.sut != compare).Should() .BeTrue("the objects do not match"); }
public void Equals_ShouldBeFalse_WhenValuesAreDifferent() { var compare = new StubValueObject("Mike", "Walsh"); this.sut.Equals(compare).Should() .BeFalse("both objects differ"); }
public void Equals_ShouldBeFalse_WhenComparedWithNull() { StubValueObject empty = null; this.sut.Equals(empty).Should() .BeFalse("system under test is being compared with null"); }
public void Equals_ShouldBeTrue_WhenValuesAreIdentical() { var compare = new StubValueObject("Chester", "Copperpot"); this.sut.Equals(compare).Should() .BeTrue("both objects share the same value"); }
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 }
public void GetHashCode_ShouldCreateValidHashCode() { var hashA = this.sut.GetHashCode(); var hashB = new StubValueObject("Chester", "Copperpot").GetHashCode(); hashA.Should() .Be( hashB, "both objects share the same value"); }
public ValueObjectTests() { this.sut = new StubValueObject("Chester", "Copperpot"); }