当前位置: 首页>>代码示例>>C#>>正文


C# InMemoryRepository.GetUserByIdentity方法代码示例

本文整理汇总了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);
            }
开发者ID:woloski,项目名称:JabbR,代码行数:18,代码来源:IdentityLinkerFacts.cs

示例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);
            }
开发者ID:woloski,项目名称:JabbR,代码行数:21,代码来源:IdentityLinkerFacts.cs

示例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);
            }
开发者ID:Polows,项目名称:JabbR,代码行数:20,代码来源:ChatServiceFacts.cs

示例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);
            }
开发者ID:Polows,项目名称:JabbR,代码行数:14,代码来源:ChatServiceFacts.cs

示例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);
            }
开发者ID:QuickenLoans,项目名称:JabbR,代码行数:29,代码来源:ChatServiceFacts.cs

示例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);
            }
开发者ID:QuickenLoans,项目名称:JabbR,代码行数:24,代码来源:ChatServiceFacts.cs

示例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);
            }
开发者ID:arri-cc,项目名称:JabbR,代码行数:22,代码来源:ChatServiceFacts.cs

示例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);
            }
开发者ID:arri-cc,项目名称:JabbR,代码行数:16,代码来源:ChatServiceFacts.cs


注:本文中的InMemoryRepository.GetUserByIdentity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。