Ejemplo n.º 1
0
        public async Task AddAsync(string jobOfferId, string content)
        {
            _addBearerTokenService.AddBearerToken(_client);

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

            await _client.JobofferPropositionPostAsync(command);
        }
Ejemplo n.º 2
0
        public void Should_Have_Error_When_Content_Is_Invalid_Format()
        {
            //Arrange 
            var command = new CreateJobOfferPropositionCommand() { Content = "Test/" };

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

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

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

            //Assert
            result.ShouldHaveValidationErrorFor(x => x.Content);
        }
Ejemplo n.º 4
0
        public void Handle_InvalidJobOfferPropositionId_ThrowsNotFoundException()
        {
            //Arrange
            var handler = new CreateJobOfferPropositionCommandHandler(_mockJobOfferRepository.Object, _mapper, _logger.Object, _mockJobOfferPropositionRepository.Object, _mockUriService.Object);

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

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

            //Assert
            func.ShouldThrowAsync <NotFoundException>();
        }
Ejemplo n.º 5
0
        public async Task Handle_ValidJobOfferProposition_ReturnsSpecyficType()
        {
            //Arrange
            var handler = new CreateJobOfferPropositionCommandHandler(_mockJobOfferRepository.Object, _mapper, _logger.Object, _mockJobOfferPropositionRepository.Object, _mockUriService.Object);

            var command = new CreateJobOfferPropositionCommand()
            {
                Content    = "JobOfferProposition 1",
                JobOfferId = "1"
            };

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

            //Assert
            result.ShouldBeOfType <CreateJobOfferPropositionCommandResponse>();
        }
Ejemplo n.º 6
0
        public async Task Handle_ValidJobOfferProposition_AddedToJobOfferPropositionRepository()
        {
            //Arrange
            var handler = new CreateJobOfferPropositionCommandHandler(_mockJobOfferRepository.Object, _mapper, _logger.Object, _mockJobOfferPropositionRepository.Object, _mockUriService.Object);

            var command = new CreateJobOfferPropositionCommand()
            {
                Content    = "JobOfferProposition 1",
                JobOfferId = "1"
            };

            var itemsCountBefore = (await _mockJobOfferPropositionRepository.Object.GetAllAsync()).Count;

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

            var itemsCountAfter = (await _mockJobOfferPropositionRepository.Object.GetAllAsync()).Count;

            //Assert
            itemsCountAfter.ShouldBe(itemsCountBefore + 1);
        }
Ejemplo n.º 7
0
        public async Task <ActionResult> Create([FromBody] CreateJobOfferPropositionCommand command)
        {
            var response = await Mediator.Send(command);

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