本文整理汇总了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));
}
示例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"));
}
示例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);
}
示例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));
}
示例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);
}
示例6: ThrowsIfPasswordIsTooShort
public void ThrowsIfPasswordIsTooShort()
{
var repository = new InMemoryRepository();
var service = new ChatService(repository);
Assert.Throws<InvalidOperationException>(() => service.AddUser("SomeUser", clientId: null, password: "short"));
}
示例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));
}
示例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));
}
示例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));
}
示例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);
}
示例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);
}
示例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);
}