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); }
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); }
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()); }