コード例 #1
0
        public void GetHashCode_ValuesAreEqual_ReturnsSameHashCode()
        {
            // arrange
            var sut1 = new LiteralToken(new SourceLocation(3, 6), 'a');
            var sut2 = new LiteralToken(new SourceLocation(3, 6), 'a');

            // act
            var hashCode1 = sut1.GetHashCode();
            var hashCode2 = sut2.GetHashCode();

            // assert
            Assert.Equal(hashCode1, hashCode2);
        }
コード例 #2
0
        public void GetHashCode_ValuesAreNotEqual_ReturnsDifferentHashCodes()
        {
            // arrange
            var sut1 = new LiteralToken(new SourceLocation(3, 6), 'a');
            var sut2 = new LiteralToken(new SourceLocation(3, 6), 'b');

            // act
            var hashCode1 = sut1.GetHashCode();
            var hashCode2 = sut2.GetHashCode();

            // act, assert
            Assert.NotEqual(hashCode1, hashCode2);
        }
コード例 #3
0
ファイル: TokenTest.cs プロジェクト: wizofaus/Stubble
        public void LiteralToken_Uniqueness()
        {
            var str     = new StringSlice("foo");
            var literal = new LiteralToken
            {
                Content = new[] { str },
                ContentStartPosition = 0,
                ContentEndPosition   = 2,
                Indent       = 0,
                IsClosed     = true,
                IsWhitespace = false
            };

            var literal2 = new LiteralToken
            {
                Content = new[] { str },
                ContentStartPosition = 0,
                ContentEndPosition   = 2,
                Indent       = 0,
                IsClosed     = true,
                IsWhitespace = false
            };

            var literal3 = new LiteralToken
            {
                Content = new[] { new StringSlice("foobar") },
                ContentStartPosition = 0,
                ContentEndPosition   = 5,
                Indent       = 0,
                IsClosed     = true,
                IsWhitespace = false
            };

            Assert.False(literal.Equals(null));
            Assert.Equal(literal, literal2);
            Assert.NotEqual(literal, literal3);
            Assert.Equal(literal.GetHashCode(), literal2.GetHashCode());
            Assert.NotEqual(literal.GetHashCode(), literal3.GetHashCode());
        }