Example #1
0
        public void GetHashCodeIsSameForEquivalentSubstrings()
        {
            const string s1 = "Hello";
            const string s2 = "Hello";

            var ss1 = new Substring(s1, 2);
            var ss2 = new Substring(s2, 2);

            ss1.GetHashCode().Should().Be(ss2.GetHashCode());
        }
Example #2
0
        public void GetHashCodeIsDifferentForDifferentSubstrings()
        {
            var ss1 = new Substring("Hello", 2, 1);

            ss1.ToString().Should().Be("l");

            var ss2 = new Substring("Hello", 3, 1);

            ss2.ToString().Should().Be("l");

            ss1.GetHashCode().Should().NotBe(ss2.GetHashCode());
        }
Example #3
0
        public void GetHashCodeIsSameForEquivalentSubstrings()
        {
            const string s1 = "Hello";
            const string s2 = "Hello";

            var ss1 = new Substring(s1, 2);
            var ss2 = new Substring(s2, 2);

            ss1.GetHashCode().Should().Be(ss2.GetHashCode());
        }
Example #4
0
 public override int GetHashCode()
 {
     return(Substring != null?Substring.GetHashCode() : 0);
 }
Example #5
0
        public void GetHashCodeIsDifferentForDifferentSubstrings()
        {
            var ss1 = new Substring("Hello", 2, 1);
            ss1.ToString().Should().Be("l");

            var ss2 = new Substring("Hello", 3, 1);
            ss2.ToString().Should().Be("l");

            ss1.GetHashCode().Should().NotBe(ss2.GetHashCode());
        }