Exemplo n.º 1
0
        public void Equals_Is_Transitive()
        {
            // ARRANGE
            var instance1 = new NonEmptyString("foo");
            var instance2 = new NonEmptyString("foo");
            var instance3 = new NonEmptyString("foo");

            // ACT
            var result1 = instance1.Equals(instance2);
            var result2 = instance2.Equals(instance3);
            var result3 = instance1.Equals(instance3);

            // ASSERT
            Assert.IsTrue(result1);
            Assert.IsTrue(result2);
            Assert.IsTrue(result3);
        }
Exemplo n.º 2
0
        public void Equals_Is_Reflexive()
        {
            // ARRANGE
            var instance = new NonEmptyString("foo");

            // ACT
            var result = instance.Equals(instance);

            // ASSERT
            Assert.IsTrue(result);
        }
Exemplo n.º 3
0
        public void Equals_Returns_False_When_Obj_Is_Null()
        {
            // ARRANGE
            var instance = new NonEmptyString("foo");

            // ACT
            var result = instance.Equals(null);

            // ASSERT
            Assert.IsFalse(result);
        }
Exemplo n.º 4
0
        public void Equals_Compares_Instances_By_Value()
        {
            // ARRANGE
            var instance1 = new NonEmptyString("foo");
            var instance2 = new NonEmptyString("foo");
            var instance3 = new NonEmptyString("bar");
            var instance4 = new NonEmptyString("FOO");
            var instance5 = new NonEmptyString("fOo");

            // ACT
            var result1 = instance1.Equals(instance2);
            var result2 = instance1.Equals(instance3);
            var result3 = instance1.Equals(instance4);
            var result4 = instance1.Equals(instance5);

            // ASSERT
            Assert.IsTrue(result1);
            Assert.IsFalse(result2);
            Assert.IsFalse(result3);
            Assert.IsFalse(result4);
        }
Exemplo n.º 5
0
        public void Equals_Is_Simmetric()
        {
            // ARRANGE
            var left  = new NonEmptyString("foo");
            var right = new NonEmptyString("foo");

            // ACT
            var result1 = left.Equals(right);
            var result2 = right.Equals(left);

            // ASSERT
            Assert.IsTrue(result1);
            Assert.IsTrue(result2);
        }
Exemplo n.º 6
0
        public void Equals_Returns_False_When_Obj_Is_Not_Of_Type_NonEmptyString()
        {
            // ARRANGE
            var instance = new NonEmptyString("foo");

            // ACT
            var result1 = instance.Equals(13);
            var result2 = instance.Equals(13M);
            var result3 = instance.Equals("foo");
            var result4 = instance.Equals(new DateTime(2015, 1, 1));
            var result5 = instance.Equals(new TestClass());
            var result6 = instance.Equals(new TestStruct());

            // ASSERT
            Assert.IsFalse(result1);
            Assert.IsFalse(result2);
            Assert.IsFalse(result3);
            Assert.IsFalse(result4);
            Assert.IsFalse(result5);
            Assert.IsFalse(result6);
        }