public async Task Handle_ValidJobOffer_ReturnsSpecyficType() { //Arrange var handler = new DeleteJobOfferCommandHandler(_mockJobOfferRepository.Object, _logger.Object, _mockCurrentUserService.Object); var command = new DeleteJobOfferCommand() { Id = "1" }; //Act var result = await handler.Handle(command, CancellationToken.None); //Assert result.ShouldBeOfType <Unit>(); }
public void Handle_InvalidJobOfferId_ThrowsNotFoundException() { //Arrange var handler = new DeleteJobOfferCommandHandler(_mockJobOfferRepository.Object, _logger.Object, _mockCurrentUserService.Object); var command = new DeleteJobOfferCommand() { 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 DeleteJobOfferCommandHandler(_mockJobOfferRepository.Object, _logger.Object, _mockCurrentUserService.Object); var command = new DeleteJobOfferCommand() { Id = "1" }; //Act Func <Task> func = () => handler.Handle(command, CancellationToken.None); //Assert func.ShouldThrowAsync <ForbiddenAccessException>(); }
public async Task Handle_ValidJobOffer_DeletedToJobOfferRepository() { //Arrange var handler = new DeleteJobOfferCommandHandler(_mockJobOfferRepository.Object, _logger.Object, _mockCurrentUserService.Object); var command = new DeleteJobOfferCommand() { Id = "1" }; var jobOffersListCountBeforeDelete = (await _mockJobOfferRepository.Object.GetAllAsync()).Count; //Act await handler.Handle(command, CancellationToken.None); var jobOffersListCountAfterDelete = (await _mockJobOfferRepository.Object.GetAllAsync()).Count; //Assert jobOffersListCountAfterDelete.ShouldBe(jobOffersListCountBeforeDelete - 1); }