public async void ThrowsAnExceptionWhenTheUsernameIsEmpty() { var username = string.Empty; const string password = "******"; var command = new CreateUserAccount.Command { Username = username, Password = password }; Exception ex = await Assert.ThrowsAsync <ArgumentException>(() => SendAsync(command)); ex.Message.ShouldContain(nameof(CreateUserAccount.Command.Username)); }
public async void ThrowsAnExceptionWhenThePasswordIsNull() { var username = "******"; const string password = null; var command = new CreateUserAccount.Command { Username = username, Password = password }; Exception ex = await Assert.ThrowsAsync <ArgumentNullException>(() => SendAsync(command)); ex.Message.ShouldContain(nameof(CreateUserAccount.Command.Password)); }
public async void CreatesANewUserAccount() { const string username = "******"; const string password = "******"; var command = new CreateUserAccount.Command { Username = username, Password = password }; var userAccountId = await SendAsync(command); var userAccount = await FindAsync <ei_infrastructure.Data.POCOs.UserAccount>(userAccountId); userAccount.ShouldNotBeNull(); userAccount.Username.ShouldBe(username); userAccount.Password.ShouldBe(password); userAccount.CreationDate.ShouldBeInRange(SqlDateTime.MinValue.Value, SqlDateTime.MaxValue.Value); }
public async void ThrowsAnExceptionWhenDuplicatingUsernames() { const string username = "******"; const string password1 = "P4ss!#$%"; const string password2 = "@passw0rd"; var command1 = new CreateUserAccount.Command { Username = username, Password = password1 }; await SendAsync(command1); var command2 = new CreateUserAccount.Command { Username = username, Password = password2 }; Exception ex = await Assert.ThrowsAsync <UsernameAlreadyExistsException>(() => SendAsync(command2)); ex.Message.ShouldContain(username); }