本文整理汇总了C#中System.Collections.Generic.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# System.Collections.Generic.ToString方法的具体用法?C# System.Collections.Generic.ToString怎么用?C# System.Collections.Generic.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.Generic
的用法示例。
在下文中一共展示了System.Collections.Generic.ToString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MapToTokenModelTest
public void MapToTokenModelTest()
{
const string email = "[email protected]";
const int id = 1;
const string hash = "HashToken";
IEnumerable<string> roles = new[] {"Admin", "Student", "Teacher"};
Mock<ITokenValidation> token = new Mock<ITokenValidation>();
UserToTokenMapper mapper = new UserToTokenMapper(token.Object);
var initial = new UserWithPasswordModel()
{
Email = email,
Id = id,
HashToken = hash,
Roles = roles
};
var expected = new TokenModel()
{
EmailAndIdToken = email,
RolesToken = roles.ToString(),
HashToken = hash
};
token.Setup(x => x.EncodeEmailAndIdToken(id.ToString() + ' ' + email.ToLower()))
.Returns(email);
token.Setup(x => x.EncodeRoleToken(roles))
.Returns(roles.ToString);
var action = mapper.MapToTokenModel(initial);
Assert.IsNotNull(action);
Assert.AreEqual(action.EmailAndIdToken, expected.EmailAndIdToken);
Assert.AreEqual(action.HashToken, expected.HashToken);
Assert.AreEqual(action.RolesToken, expected.RolesToken);
}
示例2: ExpressionHasImplicitConversion
public void ExpressionHasImplicitConversion()
{
Expression t = true;
Expression f = false;
Expression i = 5;
Expression d = 3.14;
Expression s = "Hello, World!";
Expression arr = new[] {1, 2, 3};
Assert.AreEqual("true;", t.ToString());
Assert.AreEqual("false;", f.ToString());
Assert.AreEqual("5;", i.ToString());
Assert.AreEqual("3.14;", d.ToString());
Assert.AreEqual("\"Hello, World!\";", s.ToString());
Assert.AreEqual("[1,2,3];", arr.ToString());
}