예제 #1
0
        public void EqualsOperator_ShouldBeTrue_WhenBothObjectsAreNull()
        {
            StubValueObject a = null;
            StubValueObject b = null;

            (a == b).Should().BeTrue("both objects are null");
        }
예제 #2
0
        public void NotEqualsOperator_ShouldBeTrue_WhenValuesAreDifferent()
        {
            var compare = new StubValueObject("Mike", "Walsh");

            (this.sut != compare).Should()
            .BeTrue("the objects do not match");
        }
예제 #3
0
        public void Equals_ShouldBeFalse_WhenValuesAreDifferent()
        {
            var compare = new StubValueObject("Mike", "Walsh");

            this.sut.Equals(compare).Should()
            .BeFalse("both objects differ");
        }
예제 #4
0
        public void Equals_ShouldBeFalse_WhenComparedWithNull()
        {
            StubValueObject empty = null;

            this.sut.Equals(empty).Should()
            .BeFalse("system under test is being compared with null");
        }
예제 #5
0
        public void Equals_ShouldBeTrue_WhenValuesAreIdentical()
        {
            var compare = new StubValueObject("Chester", "Copperpot");

            this.sut.Equals(compare).Should()
            .BeTrue("both objects share the same value");
        }
예제 #6
0
        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);
        }
예제 #7
0
        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
        }
예제 #8
0
        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");
        }
예제 #9
0
 public ValueObjectTests()
 {
     this.sut = new StubValueObject("Chester", "Copperpot");
 }