예제 #1
0
        public async Task <ActionResult> Update([FromRoute] string id, [FromBody] UpdateJobOfferPropositionCommand command)
        {
            if (id != command.Id)
            {
                return(BadRequest());
            }

            await Mediator.Send(command);

            return(Ok());
        }
예제 #2
0
        public async Task UpdateAsync(string id, string content)
        {
            var command = new UpdateJobOfferPropositionCommand()
            {
                Id = id, Content = content
            };

            _addBearerTokenService.AddBearerToken(_client);

            await _client.JobofferPropositionPutAsync(id, command);
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }
예제 #5
0
        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>();
        }
예제 #6
0
        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>();
        }
예제 #7
0
        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");
        }