public void UsersController_Update_ShouldReturnBadRequestNotValid() { // Arrange var UserFixture = new UsersTestsFixture(); var PasswordFixture = new PasswordTestsFixture(); var controller = Fixture.GetUsersController(); var userToUpdate = Fixture.GenerateValidUserToUpdate(); var salt = PasswordFixture.GenerateSalt("0xF2AAE5AB737144A57EC78745C82F7433"); var hashPassword = new HashPassword { Password = "******", Salt = salt }; Fixture.UserAppServiceMock.Setup(c => c.GetById(1)).Returns(Fixture.GenerateValidUserToQuery()); Fixture.UserAppServiceMock.Setup(c => c.IsValid(It.IsAny <User>())) .Returns(new EntityValidationResult { Status = false }); Fixture.UserAppServiceMock.Setup(c => c.GetById(1)).Returns(UserFixture.GenerateValidUserToQuery()); Fixture.PasswordAppServiceMock.Setup(c => c.SetCriptoPassword("admin")).Returns(hashPassword); // Act var response = controller.Update(1, userToUpdate) as ObjectResult; // Assert Fluent Assertions response.StatusCode.Should().Be(400); var apiResponse = response.Value as ApiResponse; apiResponse.Message.Should().Be("Validation failed, please see details"); }
public void UsersController_Update_ShouldUpdateUser() { var UserFixture = new UsersTestsFixture(); var PasswordFixture = new PasswordTestsFixture(); // Arrange var controller = Fixture.GetUsersController(); var userToUpdate = Fixture.GenerateValidUserToUpdate(); var salt = PasswordFixture.GenerateSalt("0xF2AAE5AB737144A57EC78745C82F7433"); var hashPassword = new HashPassword { Password = "******", Salt = salt }; Fixture.UserAppServiceMock.Setup(c => c.GetById(1)).Returns(Fixture.GenerateValidUserToQuery()); Fixture.UserAppServiceMock.Setup(c => c.IsValid(It.IsAny <User>())) .Returns(new EntityValidationResult { Status = true }); Fixture.UserAppServiceMock.Setup(c => c.GetById(1)).Returns(UserFixture.GenerateValidUserToQuery()); Fixture.PasswordAppServiceMock.Setup(c => c.SetCriptoPassword("admin")).Returns(hashPassword); // Act var response = controller.Update(1, userToUpdate) as NoContentResult; // Assert Fluent Assertions response.StatusCode.Should().Be(204); }
public void UsersController_ChangeStatus_ShouldUpdateUser() { // Arrange var UserFixture = new UsersTestsFixture(); var controller = Fixture.GetUsersController(); Fixture.UserAppServiceMock.Setup(c => c.GetById(1)).Returns(Fixture.GenerateValidUserToQuery()); Fixture.UserAppServiceMock.Setup(c => c.GetById(1)).Returns(UserFixture.GenerateValidUserToQuery()); // Act var response = controller.ChangeStatus(1) as NoContentResult; // Assert Fluent Assertions response.StatusCode.Should().Be(204); }
public void UsersController_ChangeStatus_ShouldReturnNotFound() { // Arrange var UserFixture = new UsersTestsFixture(); var controller = Fixture.GetUsersController(); Fixture.UserAppServiceMock.Setup(c => c.GetById(1)).Returns(Fixture.GenerateValidUserToQuery()); Fixture.UserAppServiceMock.Setup(c => c.GetById(1)).Returns(UserFixture.GenerateValidUserToQuery()); // Act var response = controller.ChangeStatus(2) as ObjectResult; // Assert Fluent Assertions response.StatusCode.Should().Be(404); var apiResponse = response.Value as ApiResponse; apiResponse.Message.Should().Be("User Not Found"); }
public UserApplicationTests(UsersTestsFixture fixture) { Fixture = fixture; }
public UsersControllerTests(UsersTestsFixture fixture) { Fixture = fixture; }