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


C# ChatService.AddUser方法代码示例

本文整理汇总了C#中JabbR.Services.ChatService.AddUser方法的典型用法代码示例。如果您正苦于以下问题:C# ChatService.AddUser方法的具体用法?C# ChatService.AddUser怎么用?C# ChatService.AddUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JabbR.Services.ChatService的用法示例。


在下文中一共展示了ChatService.AddUser方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ThrowsIfNameIsNullOrEmpty

            public void ThrowsIfNameIsNullOrEmpty()
            {
                var repository = new InMemoryRepository();
                var service = new ChatService(new Mock<ICache>().Object, repository,new Mock<ICryptoService>().Object);

                Assert.Throws<InvalidOperationException>(() => service.AddUser(null, clientId: null, userAgent: null, password: null));
                Assert.Throws<InvalidOperationException>(() => service.AddUser(String.Empty, clientId: null, userAgent: null, password: null));
            }
开发者ID:dkouznet3,项目名称:JabbR,代码行数:8,代码来源:ChatServiceFacts.cs

示例2: ThrowsIfPasswordIsTooShort

            public void ThrowsIfPasswordIsTooShort()
            {
                var repository = new InMemoryRepository();
                var service = new ChatService(new Mock<ICache>().Object, repository,new Mock<ICryptoService>().Object);

                Assert.Throws<InvalidOperationException>(() => service.AddUser("SomeUser", clientId: null, userAgent: null, password: "short"));
            }
开发者ID:dkouznet3,项目名称:JabbR,代码行数:7,代码来源:ChatServiceFacts.cs

示例3: UnicodeNameIsValid

            public void UnicodeNameIsValid()
            {
                // Fix issue #370
                var repository = new InMemoryRepository();
                var service = new ChatService(new Mock<ICache>().Object, repository,new Mock<ICryptoService>().Object);
                var user = service.AddUser("ТарасБуга", clientId: null, userAgent: null, password: "password");

                Assert.Equal("ТарасБуга", user.Name);
            }
开发者ID:dkouznet3,项目名称:JabbR,代码行数:9,代码来源:ChatServiceFacts.cs

示例4: ThrowsIfNameInUse

            public void ThrowsIfNameInUse()
            {
                var repository = new InMemoryRepository();
                repository.Add(new ChatUser()
                {
                    Name = "taken"
                });
                var service = new ChatService(new Mock<ICache>().Object, repository,new Mock<ICryptoService>().Object);

                Assert.Throws<InvalidOperationException>(() => service.AddUser("taken", clientId: null, userAgent: null, password: null));
            }
开发者ID:dkouznet3,项目名称:JabbR,代码行数:11,代码来源:ChatServiceFacts.cs

示例5: AddsUserToRepository

            public void AddsUserToRepository()
            {
                var crypto = new Mock<ICryptoService>();
                crypto.Setup(c => c.CreateSalt()).Returns("salted");
                var repository = new InMemoryRepository();
                var service = new ChatService(new Mock<ICache>().Object, repository,crypto.Object);

                service.AddUser("SomeUser", clientId: null, userAgent: null, password: "password");

                var user = repository.GetUserByName("SomeUser");
                Assert.NotNull(user);
                Assert.Equal("SomeUser", user.Name);
                Assert.Equal("salted", user.Salt);
                Assert.Equal("8f5793009fe15c2227e3528d0507413a83dff10635d3a6acf1ba3229a03380d8", user.HashedPassword);
            }
开发者ID:dkouznet3,项目名称:JabbR,代码行数:15,代码来源:ChatServiceFacts.cs

示例6: ThrowsIfPasswordIsTooShort

            public void ThrowsIfPasswordIsTooShort()
            {
                var repository = new InMemoryRepository();
                var service = new ChatService(repository);

                Assert.Throws<InvalidOperationException>(() => service.AddUser("SomeUser", clientId: null, password: "short"));
            }
开发者ID:kiliman,项目名称:JabbR,代码行数:7,代码来源:ChatServiceFacts.cs

示例7: ThrowsIfNameIsNullOrEmpty

            public void ThrowsIfNameIsNullOrEmpty()
            {
                var repository = new InMemoryRepository();
                var service = new ChatService(repository);

                Assert.Throws<InvalidOperationException>(() => service.AddUser(null, clientId: null, password: null));
                Assert.Throws<InvalidOperationException>(() => service.AddUser(String.Empty, clientId: null, password: null));
            }
开发者ID:kiliman,项目名称:JabbR,代码行数:8,代码来源:ChatServiceFacts.cs

示例8: ThrowsIfNameIsInValid

            public void ThrowsIfNameIsInValid()
            {
                var repository = new InMemoryRepository();
                var service = new ChatService(repository);

                Assert.Throws<InvalidOperationException>(() => service.AddUser("some in valid name", clientId: null, password: null));
            }
开发者ID:kiliman,项目名称:JabbR,代码行数:7,代码来源:ChatServiceFacts.cs

示例9: ThrowsIfNameInUse

            public void ThrowsIfNameInUse()
            {
                var repository = new InMemoryRepository();
                repository.Add(new ChatUser()
                {
                    Name = "taken"
                });
                var service = new ChatService(repository);

                Assert.Throws<InvalidOperationException>(() => service.AddUser("taken", clientId: null, password: null));
            }
开发者ID:kiliman,项目名称:JabbR,代码行数:11,代码来源:ChatServiceFacts.cs

示例10: AddsUserToRepository

            public void AddsUserToRepository()
            {
                var repository = new InMemoryRepository();
                var service = new ChatService(repository);

                service.AddUser("SomeUser", clientId: null, password: "password");

                var user = repository.GetUserByName("SomeUser");
                Assert.NotNull(user);
                Assert.Equal("SomeUser", user.Name);
                Assert.Equal("password".ToSha256(), user.HashedPassword);
            }
开发者ID:kiliman,项目名称:JabbR,代码行数:12,代码来源:ChatServiceFacts.cs

示例11: 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

示例12: 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


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