public void Handle_InvalidJobOfferId_ThrowsNotFoundException() { //Arrange var handler = new UpdateJobOfferCommandHandler(_mockJobOfferRepository.Object, _mapper, _logger.Object, _mockCurrentUserService.Object); var command = new UpdateJobOfferCommand() { Id = "99" }; //Act Func <Task> func = () => handler.Handle(command, CancellationToken.None); //Assert func.ShouldThrowAsync <NotFoundException>(); }
public void Handle_NotOwnerUser_ThrowsForbiddenAccessException() { //Arrange _mockCurrentUserService.SetupGet(x => x.UserId).Returns("user2"); var handler = new UpdateJobOfferCommandHandler(_mockJobOfferRepository.Object, _mapper, _logger.Object, _mockCurrentUserService.Object); var command = new UpdateJobOfferCommand() { Id = "1" }; //Act Func <Task> func = () => handler.Handle(command, CancellationToken.None); //Assert func.ShouldThrowAsync <ForbiddenAccessException>(); }
public async Task Handle_ValidJobOffer_ReturnsSpecyficType() { //Arrange var handler = new UpdateJobOfferCommandHandler(_mockJobOfferRepository.Object, _mapper, _logger.Object, _mockCurrentUserService.Object); var command = new UpdateJobOfferCommand() { Id = "1", Position = "PositionTest", IsAvailable = true, Salary = "1000" }; //Act var result = await handler.Handle(command, CancellationToken.None); //Assert result.ShouldBeOfType <Unit>(); }
public async Task Handle_ValidJobOffer_UpdatedToJobOfferRepository() { //Arrange var handler = new UpdateJobOfferCommandHandler(_mockJobOfferRepository.Object, _mapper, _logger.Object, _mockCurrentUserService.Object); var command = new UpdateJobOfferCommand() { Id = "1", Position = "PositionTest", IsAvailable = true, Salary = "1000" }; //Act await handler.Handle(command, CancellationToken.None); var entityUpdated = await _mockJobOfferRepository.Object.GetByIdAsync(command.Id); //Assert entityUpdated.Id.ShouldBe("1"); entityUpdated.Position.ShouldBe("PositionTest"); }