public async Task AddAsync(string jobOfferId, string content)
        {
            _addBearerTokenService.AddBearerToken(_client);

            var command = new CreateJobOfferSkillCommand()
            {
                JobOfferId = jobOfferId, Content = content
            };

            await _client.JobofferSkillPostAsync(command);
        }
        public void Should_Have_Error_When_Content_Is_Invalid_Format()
        {
            //Arrange
            var command = new CreateJobOfferSkillCommand()
            {
                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 CreateJobOfferSkillCommand()
            {
                Content = new string('T', 51)
            };

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

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

            var command = new CreateJobOfferSkillCommand()
            {
                JobOfferId = "99"
            };

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

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

            var command = new CreateJobOfferSkillCommand()
            {
                JobOfferId = "1", Content = "Test"
            };

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

            //Assert
            result.ShouldBeOfType <CreateJobOfferSkillCommandResponse>();
        }
Esempio n. 6
0
        public async Task <ActionResult> Create([FromBody] CreateJobOfferSkillCommand command)
        {
            var response = await Mediator.Send(command);

            return(Created(response.Uri.ToString(), null));
        }