コード例 #1
0
        public void Equals_DifferentObjectType_ShouldReturnFalse()
        {
            // Arrange
            var field = new TestField("abc", true);

            // Act
            var result = field.Equals(123);

            // Assert
            result.Should().BeFalse();
        }
コード例 #2
0
        public void Equals_DifferentValue_ShouldReturnFalse()
        {
            // Arrange
            var fieldA = new TestField("abc", true);
            var fieldB = new TestField("abc", false);

            // Act
            var result = fieldA.Equals(fieldB);

            // Assert
            result.Should().BeFalse();
        }
コード例 #3
0
        public void Equals_SameNameAndValue_ShouldReturnTrue()
        {
            // Arrange
            var fieldA = new TestField("abc", true);
            var fieldB = new TestField("abc", true);

            // Act
            var result = fieldA.Equals(fieldB);

            // Assert
            result.Should().BeTrue();
        }
コード例 #4
0
        public void Fields_with_same_value_for_different_people_should_not_be_equal()
        {
            var value1 = Category.Designer;
            var value2 = Category.Designer;

            object field1 = new TestField {
                Value = value1.Value, Person = new TestPerson(1)
            };
            object field2 = new TestField {
                Value = value2.Value, Person = new TestPerson(2)
            };

            field1.Equals(field2).ShouldBe(false);
        }
コード例 #5
0
        public void Fields_with_same_value_should_be_equal()
        {
            var value1 = Category.Developer;
            var value2 = Category.Developer;

            object field1 = new TestField {
                Value = value1.Value, Person = new Person()
            };
            object field2 = new TestField {
                Value = value2.Value
            };

            field1.Equals(field2).ShouldBe(true);
        }
コード例 #6
0
        /// <summary>
        /// Test Other Methods for TestField Object
        /// </summary>
        public void TestMethods()
        {
            testItem = new TestField()
            {
                Id             = 15L,
                Name           = "Name",
                Description    = "Description",
                MyBoolean      = true,
                MyCreditCard   = "MyCreditCard",
                MyCurrency     = 25,
                MyDateTime     = testDate,
                MyDouble       = 10,
                MyEmail        = "MyEmail",
                MyFloat        = 5,
                MyImageUrl     = "MyImageUrl",
                MyInteger      = 1,
                MyLong         = 15L,
                MyPhone        = "MyPhone",
                MyPostalCode   = "MyPostalCode",
                MyString       = "MyString",
                MyTextArea     = "MyTextArea",
                MyTicks        = 15L,
                MyUrl          = "MyUrl",
                Comments       = "Comments",
                AuditEntered   = testDate,
                AuditEnteredBy = 15L,
                AuditUpdated   = testDate,
                AuditUpdatedBy = 15L
            };

            testItem2 = new TestField()
            {
                Id             = 15L,
                Name           = "Name",
                Description    = "Description",
                MyBoolean      = true,
                MyCreditCard   = "MyCreditCard",
                MyCurrency     = 25,
                MyDateTime     = testDate,
                MyDouble       = 10,
                MyEmail        = "MyEmail",
                MyFloat        = 5,
                MyImageUrl     = "MyImageUrl",
                MyInteger      = 1,
                MyLong         = 15L,
                MyPhone        = "MyPhone",
                MyPostalCode   = "MyPostalCode",
                MyString       = "MyString",
                MyTextArea     = "MyTextArea",
                MyTicks        = 15L,
                MyUrl          = "MyUrl",
                Comments       = "Comments",
                AuditEntered   = testDate,
                AuditEnteredBy = 15L,
                AuditUpdated   = testDate,
                AuditUpdatedBy = 15L
            };

            Assert.AreEqual(testItem.GetHashCode(), testItem2.GetHashCode());
            Assert.AreEqual(testItem.GetType(), testItem2.GetType());
            Assert.AreEqual(testItem.ToJson(), testItem2.ToJson());
            Assert.AreEqual(testItem.ToString(), testItem2.ToString());
            Assert.IsTrue(testItem.Equals(testItem2));
            Assert.IsTrue(testItem2.Equals(testItem));
            Assert.IsTrue(testItem == testItem2);
            Assert.IsFalse(testItem2 != testItem);
        }