本文整理汇总了C#中Token.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# Token.Equals方法的具体用法?C# Token.Equals怎么用?C# Token.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Token
的用法示例。
在下文中一共展示了Token.Equals方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Equals
public void Equals()
{
var a = new Token(TokenType.StartScope);
var b = new Token(TokenType.StartScope);
Assert.AreEqual(a, a);
Assert.AreEqual(a, b);
Assert.IsFalse(a.Equals((Token)null));
Assert.IsTrue(a.Equals(a));
Assert.IsTrue(a.Equals((object)b));
}
示例2: TokensThatAreDifferent
public void TokensThatAreDifferent()
{
var token = new Token(new Substring(" Hello ", 1, 5));
var token2 = new Token(new Substring("\"Hello\"", 1, 5), true, true);
token.Equals(token2).Should().BeFalse();
token.Equals((object)token2).Should().BeFalse();
(token == token2).Should().BeFalse();
(token != token2).Should().BeTrue();
token.GetHashCode().Should().NotBe(token2.GetHashCode());
}
示例3: TokensThatAreEqual
public void TokensThatAreEqual()
{
var token = new Token(new Substring("Hello", 0, 2));
var token2 = token;
token.Equals(token2).Should().BeTrue();
token.Equals((object)token2).Should().BeTrue();
(token == token2).Should().BeTrue();
(token != token2).Should().BeFalse();
token.GetHashCode().Should().Be(token2.GetHashCode());
}
示例4: TokenComperator
public void TokenComperator()
{
var server1 = new ServerWithAuthorizationCode("test", "testsecret",
new Uri("http://example.org/foo"),
new Uri("http://example.org/access"),
new Uri("http://example.org/test2"));
var server2 = new ServerWithAuthorizationCode("test2", "testsecret",
new Uri("http://example.org/fo32o"),
new Uri("http://example.org/access"),
new Uri("http://example.org/tesdst2"));
var resourceOwner1 = new ResourceOwner("testmann1");
var resourceOwner2 = new ResourceOwner("testmann2");
var token1 = new Token(server1,resourceOwner1);
var token2 = new Token(server1,resourceOwner2);
var token3 = new Token(server2,resourceOwner1);
var token4 = new Token(server2,resourceOwner2);
var token5 = new Token(server1,resourceOwner1);
token1.Equals(token1).Should().BeTrue();
token1.Equals(token2).Should().BeFalse();
token1.Equals(token3).Should().BeFalse();
token1.Equals(token4).Should().BeFalse();
token1.Equals(token5).Should().BeTrue();
(token1 == token5).Should().BeTrue();
(token1 == token2).Should().BeFalse();
(token1 != token2).Should().BeTrue();
(token1 == null).Should().BeFalse();
token1.Equals(42).Should().BeFalse();
token1.Equals(null).Should().BeFalse();
}
示例5: Equatable
public void Equatable()
{
Token a = new Token() {
Column = 19,
LineNumber = 87,
Content = String.Empty,
Type = TokenType.String
};
Token b = new Token() {
Column = 19,
LineNumber = 87,
Content = String.Empty,
Type = TokenType.String
};
Assert.AreEqual(a, b, "does not work with Assert.AreEqual");
Assert.IsTrue(a.Equals(b), "does not work with Equals");
}
示例6: op_Equals_objectSame
public void op_Equals_objectSame()
{
var obj = new Token("Example");
Assert.True(obj.Equals(obj as object));
}
示例7: op_Equals_objectDiffer
public void op_Equals_objectDiffer()
{
var obj = new Token("ABC");
var comparand = new Token("XYZ");
Assert.False(obj.Equals(comparand as object));
}
示例8: op_Equals_object
public void op_Equals_object()
{
var obj = new Token("Example");
var comparand = new Token("Example");
Assert.True(obj.Equals(comparand as object));
}
示例9: op_Equals_TokenUnequal_StringComparison
public void op_Equals_TokenUnequal_StringComparison()
{
var obj = new Token("ABC");
var comparand = new Token("XYZ");
Assert.False(obj.Equals(comparand, StringComparison.OrdinalIgnoreCase));
}
示例10: op_Equals_TokenUnequal
public void op_Equals_TokenUnequal()
{
var obj = new Token("ABC");
var comparand = new Token("XYZ");
Assert.False(obj.Equals(comparand));
}
示例11: op_Equals_TokenSame
public void op_Equals_TokenSame()
{
var obj = new Token("Example");
var comparand = obj;
Assert.True(obj.Equals(comparand));
}
示例12: op_Equals_TokenEqual_StringComparison
public void op_Equals_TokenEqual_StringComparison()
{
var obj = new Token("EXAMPLE");
var comparand = new Token("example");
Assert.True(obj.Equals(comparand, StringComparison.OrdinalIgnoreCase));
}
示例13: TokenTests_Equals_Object_ShouldReturnFalseForDifferentType
public void TokenTests_Equals_Object_ShouldReturnFalseForDifferentType()
{
// Arrange
var lhs = new Token(TokenType.Number, "1", 0);
var rhs = new Guid();
// Act
var result = lhs.Equals(rhs);
// Assert
Assert.IsFalse(result);
}
示例14: ATokenIsNotAString
public void ATokenIsNotAString()
{
var token = new Token(new Substring("Hello", 0, 2));
token.Equals("He").Should().BeFalse();
}