public async Task PostAsync_SucceedsWithOverlappingPeriodsInDifferentInputSources()
        {
            //Arrange
            var request = new HolidayCalculationRequestModel()
            {
                Hpa  = null,
                Htnp = new List <HolidayTakenNotPaidCalculationRequestModel>()
                {
                    new HolidayTakenNotPaidCalculationRequestModel(InputSource.Rp14a, new DateTime(2018, 10, 6), new DateTime(2018, 10, 6), new DateTime(2018, 9, 10), new DateTime(2018, 9, 18), 320m, new List <string> {
                        "1", "2", "3", "4", "5"
                    }, 6, true),
                    new HolidayTakenNotPaidCalculationRequestModel(InputSource.Rp1, new DateTime(2018, 10, 6), new DateTime(2018, 10, 6), new DateTime(2018, 9, 18), new DateTime(2018, 9, 20), 320m, new List <string> {
                        "1", "2", "3", "4", "5"
                    }, 6, true),
                }
            };
            var response = HolidayControllerTestsDataGenerator.GetValidResponseData();

            _service.Setup(m => m.PerformHolidayCalculationAsync(request, _confOptions)).ReturnsAsync(response);
            var controller = new HolidayController(_service.Object, _mockLogger.Object, _confOptions);

            //Act
            var result = await controller.PostAsync(request);

            //Assert
            var okObjectRequest = result.Should().BeOfType <OkObjectResult>().Subject;

            okObjectRequest.StatusCode.Should().Be((int)System.Net.HttpStatusCode.OK);
        }
        public async Task PostAsync_FailsWithBadRequest_WhenThereIsAHtnpValidationError(HolidayTakenNotPaidCalculationRequestModel htnpRequest, string expectedErrorMessage)
        {
            //Arrange
            var request = new HolidayCalculationRequestModel()
            {
                Htnp = new List <HolidayTakenNotPaidCalculationRequestModel>()
                {
                    htnpRequest
                }
            };

            var controller = new HolidayController(_service.Object, _mockLogger.Object, _confOptions);

            //Act
            var result = await controller.PostAsync(request);

            //Assert
            var badRequestObjectRequest = result.Should().BeOfType <BadRequestObjectResult>().Subject;

            badRequestObjectRequest.StatusCode.Should().Be((int)System.Net.HttpStatusCode.BadRequest);

            _mockLogger.Verify(x => x.Log(
                                   LogLevel.Error,
                                   It.IsAny <EventId>(),
                                   It.Is <object>(v => v.ToString().Contains(expectedErrorMessage)),
                                   null,
                                   It.IsAny <Func <object, Exception, string> >()
                                   ));
        }
        public async Task PostAsync_Succeeds_WithRP14aDataAndRP1NotRequiredOverride()
        {
            //Arrange
            var request = new HolidayCalculationRequestModel
            {
                Rp1NotRequired   = true,
                Rp14aNotRequired = true,
                Hpa = new HolidayPayAccruedCalculationRequestModel
                {
                    InsolvencyDate           = new DateTime(2017, 03, 22),
                    EmpStartDate             = new DateTime(2016, 12, 19),
                    DismissalDate            = new DateTime(2017, 03, 20),
                    ContractedHolEntitlement = 25,
                    HolidayYearStart         = new DateTime(2017, 01, 01),
                    IsTaxable    = true,
                    PayDay       = (int)DayOfWeek.Saturday,
                    ShiftPattern = new List <string> {
                        "1", "2", "3", "4", "5"
                    },
                    WeeklyWage      = 243.25m,
                    DaysCFwd        = 5.5m,
                    DaysTaken       = 3.5m,
                    IpConfirmedDays = 25
                },
                Htnp = new List <HolidayTakenNotPaidCalculationRequestModel>()
                {
                    new HolidayTakenNotPaidCalculationRequestModel()
                    {
                        InputSource      = InputSource.Rp14a,
                        InsolvencyDate   = new DateTime(2018, 01, 10),
                        DismissalDate    = new DateTime(2018, 01, 03),
                        UnpaidPeriodFrom = new DateTime(2017, 12, 12),
                        UnpaidPeriodTo   = new DateTime(2017, 12, 29),
                        WeeklyWage       = 306.85m,
                        ShiftPattern     = new List <string> {
                            "1", "2", "3", "4", "5"
                        },
                        PayDay    = 6,
                        IsTaxable = true
                    },
                }
            };
            var response = new HolidayCalculationResponseDTO();

            _service.Setup(m => m.PerformHolidayCalculationAsync(request, _confOptions)).ReturnsAsync(response);
            var controller = new HolidayController(_service.Object, _mockLogger.Object, _confOptions);

            //Act
            var result = await controller.PostAsync(request);

            //Assert
            var okObjectRequest = result.Should().BeOfType <OkObjectResult>().Subject;

            okObjectRequest.StatusCode.Should().Be((int)System.Net.HttpStatusCode.OK);
        }
        public async Task PostAsync_Succeeds()
        {
            //Arrange
            var request  = HolidayControllerTestsDataGenerator.GetValidRequestData();
            var response = HolidayControllerTestsDataGenerator.GetValidResponseData();

            _service.Setup(m => m.PerformHolidayCalculationAsync(request, _confOptions)).ReturnsAsync(response);
            var controller = new HolidayController(_service.Object, _mockLogger.Object, _confOptions);

            //Act
            var result = await controller.PostAsync(request);

            //Assert
            var okObjectRequest = result.Should().BeOfType <OkObjectResult>().Subject;

            okObjectRequest.StatusCode.Should().Be((int)System.Net.HttpStatusCode.OK);
        }