本文整理汇总了C#中InMemoryRepository.GetUserById方法的典型用法代码示例。如果您正苦于以下问题:C# InMemoryRepository.GetUserById方法的具体用法?C# InMemoryRepository.GetUserById怎么用?C# InMemoryRepository.GetUserById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InMemoryRepository
的用法示例。
在下文中一共展示了InMemoryRepository.GetUserById方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExistingUserWithAnotherIdentityLogin
public void ExistingUserWithAnotherIdentityLogin()
{
var repository = new InMemoryRepository();
var service = new IdentityLinker(repository, new ChatService(new Mock<ICache>().Object, repository, new Mock<ICryptoService>().Object));
var context = FakeHttpContext();
var state = JsonConvert.SerializeObject(new { userId = "existinguser" });
// user is logged in
context.Request.Cookies.Add(new HttpCookie("jabbr.state", state));
// user already logged with another login mechanism
repository.Add(new ChatUser { Id = "existinguser", Identity = "userid100000", Name = "foo", Email = "[email protected]" });
// act
service.LinkIdentity(context, "userid100000-CHANGED", "foo-CHANGED", "[email protected]");
// assert a new user is created with the right props
var migratedUSer = repository.GetUserById("existinguser");
Assert.NotNull(migratedUSer);
Assert.Equal("userid100000-CHANGED", migratedUSer.Identity);
Assert.Equal("foo", migratedUSer.Name); // name not updated
Assert.Equal("[email protected]", migratedUSer.Email);
}