public void Register_EmailAlradyExists() { // Arrange var registration = new Contracts.Registration() { Email = "*****@*****.**", FirstName = "Unit", LastName = "Test", Password = "******" }; var user = new Database.User() { Id = Guid.NewGuid(), Email = registration.Email, FirstName = registration.FirstName, LastName = registration.LastName, Role = Database.Role.Trader }; user.UpdatePassword("PasswordBecauseItIsRequired"); _dbContext.Add(user); _dbContext.SaveChanges(); // Act // Assert var exception = Assert.Throws <ProblemDetailsException>(() => _userService.Register(registration)); Assert.Equal(HttpStatusCode.BadRequest, exception.Status); }
public void Register_With_Role() { // Arrange var registrationRequest = new Contracts.Registration() { Email = "*****@*****.**", FirstName = "Unit", LastName = "Test", Password = "******" }; // Act var registration = _userService.Register(registrationRequest, Database.Role.Admin); // Assert Assert.Equal(registrationRequest.Email, registration.Email); Assert.Equal(registrationRequest.FirstName, registration.FirstName); Assert.Equal(registrationRequest.LastName, registration.LastName); Assert.Equal(Database.Role.Admin, registration.Role); }