本文整理汇总了C#中InMemoryRepository.GetUserByIdentity方法的典型用法代码示例。如果您正苦于以下问题:C# InMemoryRepository.GetUserByIdentity方法的具体用法?C# InMemoryRepository.GetUserByIdentity怎么用?C# InMemoryRepository.GetUserByIdentity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InMemoryRepository
的用法示例。
在下文中一共展示了InMemoryRepository.GetUserByIdentity方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FirstTimeUserLogin
public void FirstTimeUserLogin()
{
var repository = new InMemoryRepository();
var service = new IdentityLinker(repository, new ChatService(new Mock<ICache>().Object, repository, new Mock<ICryptoService>().Object));
var context = FakeHttpContext();
context.Request.Cookies.Add(new HttpCookie("jabbr.state", null)); // user is not logged in
// act
service.LinkIdentity(context, "userid100000", "foo", "[email protected]");
// assert a new user is created with the right props
var newUser = repository.GetUserByIdentity("userid100000");
Assert.NotNull(newUser);
Assert.Equal("userid100000", newUser.Identity);
Assert.Equal("foo", newUser.Name);
Assert.Equal("[email protected]", newUser.Email);
}
示例2: ExistingUserLoginUpdatesEmailAndGravatar
public void ExistingUserLoginUpdatesEmailAndGravatar()
{
var repository = new InMemoryRepository();
var service = new IdentityLinker(repository, new ChatService(new Mock<ICache>().Object, repository, new Mock<ICryptoService>().Object));
var context = FakeHttpContext();
// user is not logged in
context.Request.Cookies.Add(new HttpCookie("jabbr.state", null));
// user at least logged in once
repository.Add(new ChatUser { Identity = "userid100000", Name = "foo", Email = "[email protected]" });
// act (update email)
service.LinkIdentity(context, "userid100000", "foo", "[email protected]");
// assert a new user is created with the right props
var newUser = repository.GetUserByIdentity("userid100000");
Assert.NotNull(newUser);
Assert.Equal("userid100000", newUser.Identity);
Assert.Equal("foo", newUser.Name);
Assert.Equal("[email protected]", newUser.Email);
}
示例3: AddsNumberToUserNameIfTaken
public void AddsNumberToUserNameIfTaken()
{
var repository = new InMemoryRepository();
repository.Add(new ChatUser
{
Name = "david",
Id = "1"
});
var service = new ChatService(repository, null);
service.AddUser("david", "idenity", null);
var user = repository.GetUserByIdentity("idenity");
Assert.NotNull(user);
Assert.Equal("david1", user.Name);
Assert.Equal("idenity", user.Identity);
Assert.Null(user.Email);
Assert.Null(user.Hash);
}
示例4: AddsAuthUserToRepository
public void AddsAuthUserToRepository()
{
var repository = new InMemoryRepository();
var service = new ChatService(repository, null);
service.AddUser("SomeUser", "identity", "email");
var user = repository.GetUserByIdentity("identity");
Assert.NotNull(user);
Assert.Equal("SomeUser", user.Name);
Assert.Equal("identity", user.Identity);
Assert.Equal("email", user.Email);
Assert.Equal("0c83f57c786a0b4a39efab23731c7ebc", user.Hash);
}
示例5: AddsNumberToUserNameIfTaken
public void AddsNumberToUserNameIfTaken()
{
var repository = new InMemoryRepository();
repository.Add(new ChatUser
{
Name = "david",
Id = "1"
});
var service = new MembershipService(repository, new Mock<ICryptoService>().Object);
var claims = new List<Claim>();
claims.Add(new Claim(ClaimTypes.Name, "david"));
claims.Add(new Claim(ClaimTypes.AuthenticationMethod, "provider"));
claims.Add(new Claim(ClaimTypes.NameIdentifier, "identity"));
var claimsIdentity = new ClaimsIdentity(claims);
var claimsPrincipal = new ClaimsPrincipal(claimsIdentity);
service.AddUser(claimsPrincipal);
var user = repository.GetUserByIdentity("provider", "identity");
Assert.NotNull(user);
Assert.Equal("david1", user.Name);
Assert.Null(user.Identity);
Assert.Null(user.Email);
Assert.Null(user.Hash);
Assert.Equal(1, user.Identities.Count);
Assert.Equal("identity", user.Identities.First().Identity);
}
示例6: AddsAuthUserToRepository
public void AddsAuthUserToRepository()
{
var repository = new InMemoryRepository();
var service = new MembershipService(repository, new Mock<ICryptoService>().Object);
var claims = new List<Claim>();
claims.Add(new Claim(ClaimTypes.Name, "SomeUser"));
claims.Add(new Claim(ClaimTypes.AuthenticationMethod, "provider"));
claims.Add(new Claim(ClaimTypes.NameIdentifier, "identity"));
claims.Add(new Claim(ClaimTypes.Email, "email"));
var claimsIdentity = new ClaimsIdentity(claims);
var claimsPrincipal = new ClaimsPrincipal(claimsIdentity);
service.AddUser(claimsPrincipal);
var user = repository.GetUserByIdentity("provider", "identity");
Assert.NotNull(user);
Assert.Equal("SomeUser", user.Name);
Assert.Null(user.Identity);
Assert.Null(user.Email);
Assert.Equal("0c83f57c786a0b4a39efab23731c7ebc", user.Hash);
Assert.Equal(1, user.Identities.Count);
Assert.Equal("email", user.Identities.First().Email);
}
示例7: AddsNumberToUserNameIfTaken
public void AddsNumberToUserNameIfTaken()
{
var repository = new InMemoryRepository();
repository.Add(new ChatUser
{
Name = "david",
Id = "1"
});
var service = new MembershipService(repository, new Mock<ICryptoService>().Object);
service.AddUser("david", "provider", "identity", email: null);
var user = repository.GetUserByIdentity("provider", "identity");
Assert.NotNull(user);
Assert.Equal("david1", user.Name);
Assert.Null(user.Identity);
Assert.Null(user.Email);
Assert.Null(user.Hash);
Assert.Equal(1, user.Identities.Count);
Assert.Equal("identity", user.Identities.First().Identity);
}
示例8: AddsAuthUserToRepository
public void AddsAuthUserToRepository()
{
var repository = new InMemoryRepository();
var service = new MembershipService(repository, new Mock<ICryptoService>().Object);
service.AddUser("SomeUser", "provider", "identity", "email");
var user = repository.GetUserByIdentity("provider", "identity");
Assert.NotNull(user);
Assert.Equal("SomeUser", user.Name);
Assert.Null(user.Identity);
Assert.Null(user.Email);
Assert.Equal("0c83f57c786a0b4a39efab23731c7ebc", user.Hash);
Assert.Equal(1, user.Identities.Count);
Assert.Equal("email", user.Identities.First().Email);
}