Beispiel #1
0
        public void GetHashCode_SameNameAndValue_ShouldReturnSameHash()
        {
            // Arrange
            var fieldA = new TestField("abc", true);
            var fieldB = new TestField("abc", true);

            // Act
            var hashA = fieldA.GetHashCode();
            var hashB = fieldB.GetHashCode();

            // Assert
            hashA.Should().Be(hashB);
        }
Beispiel #2
0
        public void GetHashCode_DifferentValue_ShouldReturnDifferentHash()
        {
            // Arrange
            var fieldA = new TestField("abc", true);
            var fieldB = new TestField("abc", false);

            // Act
            var hashA = fieldA.GetHashCode();
            var hashB = fieldB.GetHashCode();

            // Assert
            hashA.Should().NotBe(hashB);
        }
        /// <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);
        }