public async Task <ActionResult> Update([FromRoute] string id, [FromBody] UpdateJobOfferPropositionCommand command) { if (id != command.Id) { return(BadRequest()); } await Mediator.Send(command); return(Ok()); }
public async Task UpdateAsync(string id, string content) { var command = new UpdateJobOfferPropositionCommand() { Id = id, Content = content }; _addBearerTokenService.AddBearerToken(_client); await _client.JobofferPropositionPutAsync(id, command); }
public void Should_Have_Error_When_Content_Is_Invalid_Format() { //Arrange var command = new UpdateJobOfferPropositionCommand() { Content = "Test/" }; //Act var result = _validator.TestValidate(command); //Assert result.ShouldHaveValidationErrorFor(x => x.Content); }
public void Should_Have_Error_When_Content_Is_Greater_Than_50_Characters() { //Arrange var command = new UpdateJobOfferPropositionCommand() { Content = new string('T', 51) }; //Act var result = _validator.TestValidate(command); //Assert result.ShouldHaveValidationErrorFor(x => x.Content); }
public void Handle_InvalidJobOfferPropositionId_ThrowsNotFoundException() { //Arrange var handler = new UpdateJobOfferPropositionCommandHandler(_mapper, _logger.Object, _mockJobOfferPropositionRepository.Object); var command = new UpdateJobOfferPropositionCommand() { Id = "99" }; //Act Func <Task> func = () => handler.Handle(command, CancellationToken.None); //Assert func.ShouldThrowAsync <NotFoundException>(); }
public async Task Handle_ValidJobOfferProposition_ReturnSpecyficType() { //Arrange var handler = new UpdateJobOfferPropositionCommandHandler(_mapper, _logger.Object, _mockJobOfferPropositionRepository.Object); var command = new UpdateJobOfferPropositionCommand() { Id = "1", Content = "Updated 1" }; //Act var result = await handler.Handle(command, CancellationToken.None); //Assert result.ShouldBeOfType <Unit>(); }
public async Task Handle_ValidJobOfferProposition_UpdatedToJobOfferPropositionRepository() { //Arrange var handler = new UpdateJobOfferPropositionCommandHandler(_mapper, _logger.Object, _mockJobOfferPropositionRepository.Object); var command = new UpdateJobOfferPropositionCommand() { Id = "1", Content = "Updated 1" }; //Act await handler.Handle(command, CancellationToken.None); var entity = await _mockJobOfferPropositionRepository.Object.GetByIdAsync(command.Id); //Assert entity.Content.ShouldBe("Updated 1"); }