コード例 #1
0
        public void EqualsAndGetHashCodeDoNotThrowIfValueIsNullOrEmpty()
        {
            // Arrange
            var attribute1 = new RazorDirectiveAttribute("foo", null);
            var attribute2 = new RazorDirectiveAttribute("foo", "BAr");

            // Act
            bool result = attribute1.Equals(attribute2);
            var hashCode = attribute1.GetHashCode();

            // Assert
            Assert.False(result);
            // If we've got this far, GetHashCode did not throw
        }
コード例 #2
0
        public void EqualsAndGetHashCodeIgnoresCase()
        {
            // Arrange
            var attribute1 = new RazorDirectiveAttribute("foo", "bar");
            var attribute2 = new RazorDirectiveAttribute("fOo", "BAr");

            // Act
            var hashCode1 = attribute1.GetHashCode();
            var hashCode2 = attribute2.GetHashCode();

            // Assert
            Assert.Equal(attribute1, attribute2);
            Assert.Equal(hashCode1, hashCode2);
        }
コード例 #3
0
        public void EqualsAndGetHashCodeDoNotThrowIfValueIsNullOrEmpty()
        {
            // Arrange
            var attribute1 = new RazorDirectiveAttribute("foo", null);
            var attribute2 = new RazorDirectiveAttribute("foo", "BAr");

            // Act
            bool result   = attribute1.Equals(attribute2);
            var  hashCode = attribute1.GetHashCode();

            // Assert
            Assert.False(result);
            // If we've got this far, GetHashCode did not throw
        }
コード例 #4
0
        public void EqualsAndGetHashCodeIgnoresCase()
        {
            // Arrange
            var attribute1 = new RazorDirectiveAttribute("foo", "bar");
            var attribute2 = new RazorDirectiveAttribute("fOo", "BAr");

            // Act
            var hashCode1 = attribute1.GetHashCode();
            var hashCode2 = attribute2.GetHashCode();

            // Assert
            Assert.Equal(attribute1, attribute2);
            Assert.Equal(hashCode1, hashCode2);
        }
コード例 #5
0
        public void EqualsAndGetHashCodeReturnDifferentValuesForNullAndEmpty()
        {
            // Arrange
            var attribute1 = new RazorDirectiveAttribute("foo", null);
            var attribute2 = new RazorDirectiveAttribute("foo", "");

            // Act
            bool result = attribute1.Equals(attribute2);
            var hashCode1 = attribute1.GetHashCode();
            var hashCode2 = attribute2.GetHashCode();

            // Assert
            Assert.False(result);
            Assert.NotEqual(hashCode1, hashCode2);
        }
コード例 #6
0
        public void EqualsAndGetHashCodeReturnDifferentValuesForNullAndEmpty()
        {
            // Arrange
            var attribute1 = new RazorDirectiveAttribute("foo", null);
            var attribute2 = new RazorDirectiveAttribute("foo", "");

            // Act
            bool result    = attribute1.Equals(attribute2);
            var  hashCode1 = attribute1.GetHashCode();
            var  hashCode2 = attribute2.GetHashCode();

            // Assert
            Assert.False(result);
            Assert.NotEqual(hashCode1, hashCode2);
        }