Esempio n. 1
0
        public void Equals_ValuesAreEqual_ReturnsTrue()
        {
            // arrange
            var sut1 = new LiteralToken(new SourceLocation(3, 6), 'a');
            var sut2 = new LiteralToken(new SourceLocation(3, 6), 'a');

            // act
            var result = sut1.Equals(sut2);

            // assert
            Assert.True(result);
        }
Esempio n. 2
0
        public void Equals_ValueIsDifferent_ReturnsFalse()
        {
            // arrange
            var sut1 = new LiteralToken(new SourceLocation(3, 6), 'a');
            var sut2 = new LiteralToken(new SourceLocation(3, 6), 'b');

            // act
            var result = sut1.Equals(sut2);

            // assert
            Assert.False(result);
        }
Esempio n. 3
0
        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());
        }