public IHttpActionResult AddUserAccount(Guid userId, AddUserAccountCommand command) { if (command == null) { throw new ArgumentNullException("command"); } if (string.IsNullOrWhiteSpace(command.Name)) { throw new ArgumentException("Account name must be defined."); } if (userId == Guid.Empty) { throw new ArgumentException("userId must be defined."); } AccountType type = ParseAccountType(command.Type); if (type == AccountType.Password) { identityManagementService.AddUserAccount(userId, command.Name, command.Password); } else { identityManagementService.AddExternalUserAccount(userId, type, command.Name); } return Ok(); }
public void AddExternalUserAccount() { Guid userId = Guid.NewGuid(); var command = new AddUserAccountCommand { Name = "someUser", Type = "ActiveDirectory" }; var result = sut.AddUserAccount(userId, command) as OkResult; Assert.IsNotNull(result); identityManagementService.Received(1).AddExternalUserAccount(userId, AccountType.ActiveDirectory, command.Name); }
public void AddPasswordUserAccount() { Guid userId = Guid.NewGuid(); var command = new AddUserAccountCommand { Name = "someUser", Password = "******", Type = "Password" }; var result = sut.AddUserAccount(userId, command) as OkResult; Assert.IsNotNull(result); identityManagementService.Received(1).AddUserAccount(userId, command.Name, command.Password); }