示例#1
0
        public void Compares_Equal_When_Path_And_Content_Are_The_Same()
        {
            AdditionalText text1 = new InMemoryAdditionalText(@"c:\a\b\c.txt", "abc");
            AdditionalText text2 = new InMemoryAdditionalText(@"c:\a\b\c.txt", "abc");

            Assert.NotEqual(text1, text2);
            Assert.Equal(text1, text2, AdditionalTextComparer.Instance);
        }
示例#2
0
        public void Not_Equal_When_Contents_Differ()
        {
            AdditionalText text1 = new InMemoryAdditionalText(@"c:\a\b\c.txt", "abc");
            AdditionalText text2 = new InMemoryAdditionalText(@"c:\a\b\c.txt", "def");

            Assert.NotEqual(text1, text2, AdditionalTextComparer.Instance);

            var comparerHash1 = AdditionalTextComparer.Instance.GetHashCode(text1);
            var comparerHash2 = AdditionalTextComparer.Instance.GetHashCode(text2);

            Assert.NotEqual(comparerHash1, comparerHash2);
        }
示例#3
0
        public void HashCodes_Match_When_Path_And_Content_Are_The_Same()
        {
            AdditionalText text1 = new InMemoryAdditionalText(@"c:\a\b\c.txt", "abc");
            AdditionalText text2 = new InMemoryAdditionalText(@"c:\a\b\c.txt", "abc");

            var hash1 = text1.GetHashCode();
            var hash2 = text2.GetHashCode();

            Assert.NotEqual(hash1, hash2);

            var comparerHash1 = AdditionalTextComparer.Instance.GetHashCode(text1);
            var comparerHash2 = AdditionalTextComparer.Instance.GetHashCode(text2);

            Assert.Equal(comparerHash1, comparerHash2);
        }
示例#4
0
        public void Comparison_With_Different_Path_Casing()
        {
            AdditionalText text1 = new InMemoryAdditionalText(@"c:\a\b\c.txt", "abc");
            AdditionalText text2 = new InMemoryAdditionalText(@"c:\a\B\c.txt", "abc");

            // hash codes are path case insensitive
            var comparerHash1 = AdditionalTextComparer.Instance.GetHashCode(text1);
            var comparerHash2 = AdditionalTextComparer.Instance.GetHashCode(text2);

            Assert.Equal(comparerHash1, comparerHash2);

            // but we correctly compare
            if (PathUtilities.IsUnixLikePlatform)
            {
                Assert.NotEqual(text1, text2, AdditionalTextComparer.Instance);
            }
            else
            {
                Assert.Equal(text1, text2, AdditionalTextComparer.Instance);
            }
        }