public void MapToTokenModelTest() { const string email = "*****@*****.**"; 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); }
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()); }