Пример #1
0
        public async void Should_Return_Unprocessable_If_No_Rows_Affected()
        {
            // ARRANGE
            var validator = new CreateRecruitmentMessageCommandValidator();
            var recruitmentMessageRepositoryMock = new Mock <IRecruitmentMessageRepository>();
            var loggerMock = new Mock <ILogger>();

            var handler = new CreateRecruitmentMessageCommandHandler(
                recruitmentMessageRepositoryMock.Object,
                loggerMock.Object,
                validator
                );

            recruitmentMessageRepositoryMock.Setup(x => x.InsertRecruitmentMessage(It.IsAny <Domain.Models.RecruitmentMessage.RecruitmentMessage>())).ReturnsAsync(0);

            // ACT
            var response = await handler.Handle(new CreateRecruitmentMessageCommand()
            {
                RecruitmentMessage = new Domain.Models.RecruitmentMessage.RecruitmentMessage()
                {
                    RecruiterId = "1"
                }
            }, new CancellationToken());

            // ASSERT
            Assert.Equal(CommandResultTypeEnum.UnprocessableEntity, response.Type);
            recruitmentMessageRepositoryMock.Verify(x => x.InsertRecruitmentMessage(It.IsAny <Domain.Models.RecruitmentMessage.RecruitmentMessage>()), Times.Once);
        }
Пример #2
0
        public async void Request_With_No_Id_Should_Return_Invalid_Input()
        {
            // ARRANGE
            var validator = new CreateRecruitmentMessageCommandValidator();
            var recruitmentMessageRepositoryMock = new Mock <IRecruitmentMessageRepository>();
            var loggerMock = new Mock <ILogger>();

            var handler = new CreateRecruitmentMessageCommandHandler(
                recruitmentMessageRepositoryMock.Object,
                loggerMock.Object,
                validator
                );

            // ACT
            var response = await handler.Handle(new CreateRecruitmentMessageCommand()
            {
                RecruitmentMessage = new Domain.Models.RecruitmentMessage.RecruitmentMessage()
            }, new CancellationToken());

            // ASSERT
            Assert.Equal(CommandResultTypeEnum.InvalidInput, response.Type);
        }