public async Task UpdateAsync(string id, string content)
        {
            _addBearerTokenService.AddBearerToken(_client);

            var command = new UpdateJobOfferRequirementCommand()
            {
                Id = id, Content = content
            };

            await _client.JobofferRequirementPutAsync(id, command);
        }
        public async Task <ActionResult> Update([FromRoute] string id, [FromBody] UpdateJobOfferRequirementCommand command)
        {
            if (id != command.Id)
            {
                return(BadRequest());
            }

            await Mediator.Send(command);

            return(Ok());
        }
Exemplo n.º 3
0
        public void Should_Have_Error_When_Content_Is_Invalid_Format()
        {
            //Arrange
            var command = new UpdateJobOfferRequirementCommand()
            {
                Content = "Test/"
            };

            //Act
            var result = _validator.TestValidate(command);

            //Assert
            result.ShouldHaveValidationErrorFor(x => x.Content);
        }
Exemplo n.º 4
0
        public void Should_Have_Error_When_Content_Is_Greater_Than_50_Characters()
        {
            //Arrange
            var command = new UpdateJobOfferRequirementCommand()
            {
                Content = new string('T', 51)
            };

            //Act
            var result = _validator.TestValidate(command);

            //Assert
            result.ShouldHaveValidationErrorFor(x => x.Content);
        }
        public void Handle_InvalidJobOfferRequirementId_ThrowsNotFoundException()
        {
            //Arrange
            var handler = new UpdateJobOfferRequirementCommandHandler(_mapper, _mockLogger.Object, _mockJobOfferRequirementRepository.Object);

            var command = new UpdateJobOfferRequirementCommand()
            {
                Id = "99"
            };

            //Act
            Func <Task> func = () => handler.Handle(command, CancellationToken.None);

            //Assert
            func.ShouldThrowAsync <NotFoundException>();
        }
        public async Task Handle_ValidJobOfferRequirement_ReturnsSpecyficType()
        {
            //Arrange
            var handler = new UpdateJobOfferRequirementCommandHandler(_mapper, _mockLogger.Object, _mockJobOfferRequirementRepository.Object);

            var command = new UpdateJobOfferRequirementCommand()
            {
                Id = "1", Content = "Test"
            };

            //Act
            var result = await handler.Handle(command, CancellationToken.None);

            //Assert
            result.ShouldBeOfType <Unit>();
        }
        public async Task Handle_ValidJobOfferRequirement_UpdatedToJobOfferRequirementRepository()
        {
            //Arrange
            var handler = new UpdateJobOfferRequirementCommandHandler(_mapper, _mockLogger.Object, _mockJobOfferRequirementRepository.Object);

            var command = new UpdateJobOfferRequirementCommand()
            {
                Id      = "1",
                Content = "Updated 1"
            };

            //Act
            await handler.Handle(command, CancellationToken.None);

            var entity = await _mockJobOfferRequirementRepository.Object.GetByIdAsync(command.Id);

            //Assert
            entity.Content.ShouldBe("Updated 1");
        }