Exemplo n.º 1
0
        public async Task <IActionResult> PostAsync([FromBody] APPACalculationRequestModel data)
        {
            try
            {
                if (data == null)
                {
                    ModelState.AddModelError("",
                                             "Bad payload provided; unable to parse the request , please review request data and try again");
                    _logger.LogError(400, $"Bad payload " +
                                     $"{ModelState}\n Request Data is null and could not be parsed");
                    return(BadRequest(ModelState));
                }

                var validator = new APPACalculationRequestValidator();
                if (!ModelState.IsValid || !validator.Validate(data).IsValid)
                {
                    _logger.LogError((int)HttpStatusCode.BadRequest, $"Request model not valid " +
                                     $"{ModelState}\n Request Data {JsonConvert.SerializeObject(data)} \n Errors : " +
                                     $"{validator.Validate(data).Errors.GetErrorsAsString()} ");
                    return(BadRequest(ModelState));
                }

                var result = await _appaService.PerformCalculationAsync(data, _options);

                _logger.LogInformation((int)HttpStatusCode.OK,
                                       $"Calculation performed successfully for the request data provided \n Request Data: {JsonConvert.SerializeObject(data)}");
                return(Ok(result));
            }
            catch (MissingConfigurationException exp)
            {
                _logger.LogError((int)HttpStatusCode.BadRequest,
                                 $"Calculation was not performed for the request data provided \n Request Data: {JsonConvert.SerializeObject(data)} Bad payload provided; {exp.Message}, please review request data and try again");
                return(BadRequest($"Bad payload provided; {exp.Message}, please review request data and try again"));
            }
        }
        public async Task PostAsync_Succeeds_WithNoAPData()
        {
            //Arrange
            var request = new APPACalculationRequestModel
            {
                Ap = new List <ArrearsOfPayCalculationRequestModel>(),
                Pa = new ProtectiveAwardCalculationRequestModel()
                {
                    InsolvencyDate           = new DateTime(2018, 10, 20),
                    EmploymentStartDate      = new DateTime(2016, 4, 6),
                    DismissalDate            = new DateTime(2018, 10, 20),
                    TribunalAwardDate        = new DateTime(2018, 10, 21),
                    ProtectiveAwardStartDate = new DateTime(2018, 10, 22),
                    ProtectiveAwardDays      = 90,
                    PayDay       = 6,
                    WeeklyWage   = 400M,
                    ShiftPattern = new List <string> {
                        "1", "2", "3", "4", "5"
                    }
                }
            };
            var response = new APPACalculationResponseDTO();

            _service.Setup(m => m.PerformCalculationAsync(request, _confOptions)).ReturnsAsync(response);
            var controller = new APPAController(_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_WhenThereIsAPAValidationError(ProtectiveAwardCalculationRequestModel paRequest, string expectedErrorMessage)
        {
            //Arrange
            var request = new APPACalculationRequestModel()
            {
                Pa = paRequest
            };

            var controller = new APPAController(_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 PerformCalculationAsync_PerformsAPAndPACalculationsWithOnlyPAInput()
        {
            // Arrange
            var shiftPattern = new List <string> {
                "1", "2", "3", "4", "5"
            };

            var paRequest = new ProtectiveAwardCalculationRequestModel()
            {
                InsolvencyDate           = new DateTime(2018, 10, 20),
                EmploymentStartDate      = new DateTime(2016, 4, 6),
                DismissalDate            = new DateTime(2018, 10, 20),
                TribunalAwardDate        = new DateTime(2018, 10, 21),
                ProtectiveAwardStartDate = new DateTime(2018, 10, 22),
                ProtectiveAwardDays      = 90,
                PayDay       = 6,
                WeeklyWage   = 400M,
                ShiftPattern = shiftPattern,
            };

            var paResponse = new ProtectiveAwardResponseDTO()
            {
                IsTaxable    = true,
                StatutoryMax = 508m,
                PayLines     = new List <ProtectiveAwardPayLine>()
                {
                    new ProtectiveAwardPayLine(1, new DateTime(2018, 10, 27), 0M, 400M, 80M, 28.56M, 291.44M, 0M, 0M, 0M),
                    new ProtectiveAwardPayLine(2, new DateTime(2018, 11, 3), 0M, 400M, 80M, 28.56M, 291.44M, 0M, 0M, 0M),
                    new ProtectiveAwardPayLine(3, new DateTime(2018, 11, 10), 0M, 400M, 80M, 28.56M, 291.44M, 0M, 0M, 0M),
                    new ProtectiveAwardPayLine(4, new DateTime(2018, 11, 17), 0M, 400M, 80M, 28.56M, 291.44M, 0M, 0M, 0M),
                    new ProtectiveAwardPayLine(5, new DateTime(2018, 11, 24), 0M, 400M, 80M, 28.56M, 291.44M, 0M, 0M, 0M),
                    new ProtectiveAwardPayLine(6, new DateTime(2018, 12, 1), 0M, 400M, 80M, 28.56M, 291.44M, 0M, 0M, 0M),
                    new ProtectiveAwardPayLine(7, new DateTime(2018, 12, 8), 0M, 400M, 80M, 28.56M, 291.44M, 0M, 0M, 0M),
                    new ProtectiveAwardPayLine(8, new DateTime(2018, 12, 15), 0M, 400M, 80M, 28.56M, 291.44M, 0M, 0M, 0M),
                    new ProtectiveAwardPayLine(9, new DateTime(2018, 12, 22), 0M, 400M, 80M, 28.56M, 291.44M, 0M, 0M, 0M),
                    new ProtectiveAwardPayLine(10, new DateTime(2018, 12, 29), 0M, 400M, 80M, 28.56M, 291.44M, 0M, 0M, 0M),
                    new ProtectiveAwardPayLine(11, new DateTime(2019, 1, 5), 0M, 400M, 80M, 28.56M, 291.44M, 0M, 0M, 0M),
                    new ProtectiveAwardPayLine(12, new DateTime(2019, 1, 12), 0M, 400M, 80M, 28.56M, 291.44M, 0M, 0M, 0M),
                    new ProtectiveAwardPayLine(13, new DateTime(2019, 1, 12), 0M, 400M, 80M, 28.56M, 291.44M, 0M, 0M, 0M)
                }
            };

            var request = new APPACalculationRequestModel()
            {
                Ap = null,
                Pa = paRequest
            };

            _paService.Setup(m => m.PerformProtectiveAwardCalculationAsync(paRequest, _options)).ReturnsAsync(paResponse);

            // Act
            var results = await _service.PerformCalculationAsync(request, _options);

            // Assert
            results.Ap.Should().BeNull();
            results.Pa.Should().NotBeNull();
            results.Pa.PayLines.Count(x => x.IsSelected).Should().Be(8);
        }
        public async Task PostAsync_SucceedsWithOverlappingPeriodsInDifferentInputSources()
        {
            //Arrange
            var request = new APPACalculationRequestModel()
            {
                Ap = new List <ArrearsOfPayCalculationRequestModel>()
                {
                    new ArrearsOfPayCalculationRequestModel
                    {
                        InputSource         = InputSource.Rp1,
                        InsolvencyDate      = new DateTime(2017, 03, 22),
                        EmploymentStartDate = new DateTime(2016, 12, 19),
                        DismissalDate       = new DateTime(2017, 01, 03),
                        DateNoticeGiven     = new DateTime(2016, 12, 19),
                        UnpaidPeriodFrom    = new DateTime(2016, 12, 19),
                        UnpaidPeriodTo      = new DateTime(2017, 01, 03),
                        ApClaimAmount       = 150,
                        IsTaxable           = true,
                        PayDay       = (int)DayOfWeek.Saturday,
                        ShiftPattern = new List <string> {
                            "2", "3", "4", "5", "6"
                        },
                        WeeklyWage = 243.25m
                    },
                    new ArrearsOfPayCalculationRequestModel
                    {
                        InputSource         = InputSource.Rp14a,
                        InsolvencyDate      = new DateTime(2017, 03, 22),
                        EmploymentStartDate = new DateTime(2016, 12, 19),
                        DismissalDate       = new DateTime(2017, 01, 03),
                        DateNoticeGiven     = new DateTime(2016, 12, 19),
                        UnpaidPeriodFrom    = new DateTime(2017, 1, 3),
                        UnpaidPeriodTo      = new DateTime(2017, 01, 4),
                        ApClaimAmount       = 150,
                        IsTaxable           = true,
                        PayDay       = (int)DayOfWeek.Saturday,
                        ShiftPattern = new List <string> {
                            "2", "3", "4", "5", "6"
                        },
                        WeeklyWage = 243.25m
                    }
                },
                Pa = null
            };
            var response = APPAControllerTestsDataGenerator.GetValidResponseData();

            _service.Setup(m => m.PerformCalculationAsync(request, _confOptions)).ReturnsAsync(response);
            var controller = new APPAController(_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);
        }
Exemplo n.º 6
0
        public async Task <APPACalculationResponseDTO> PerformCalculationAsync(APPACalculationRequestModel data, IOptions <ConfigLookupRoot> options)
        {
            var allWeeks      = new List <IWeeklyResult>();
            var result        = new APPACalculationResponseDTO();
            var rp1TraceInfo  = new TraceInfo();
            var rp14TraceInfo = new TraceInfo();

            if (data.Ap != null && data.Ap.Any())
            {
                result.Ap = new ArrearsOfPayAggregateOutput();
                result.Ap.RP1ResultsList = await _apService.PerformCalculationAsync(data.Ap, InputSource.Rp1, options, rp1TraceInfo);

                result.Ap.RP14aResultsList = await _apService.PerformCalculationAsync(data.Ap, InputSource.Rp14a, options, rp14TraceInfo);

                var rp1Any = result.Ap.RP1ResultsList != null && result.Ap.RP1ResultsList.WeeklyResult.Any();
                var rp1Sum = rp1Any ? result.Ap.RP1ResultsList.WeeklyResult.Sum(x => x.NetEntitlement) : 0M;

                var rp14aAny = result.Ap.RP14aResultsList != null && result.Ap.RP14aResultsList.WeeklyResult.Any();
                var rp14aSum = rp14aAny ? result.Ap.RP14aResultsList.WeeklyResult.Sum(x => x.NetEntitlement) : 0M;

                if ((rp1Any && rp1Sum == 0) || (rp1Sum > 0 && rp1Sum < rp14aSum) || (rp1Any && !rp14aAny))
                {
                    result.Ap.SelectedInputSource = InputSource.Rp1;
                    allWeeks.AddRange(result.Ap.RP1ResultsList.WeeklyResult);
                    result.Ap.TraceInfo = await rp1TraceInfo.ConvertToJson();
                }
                else
                {
                    result.Ap.SelectedInputSource = InputSource.Rp14a;
                    allWeeks.AddRange(result.Ap.RP14aResultsList.WeeklyResult);
                    result.Ap.TraceInfo = await rp14TraceInfo.ConvertToJson();
                }
            }

            if (data.Pa != null)
            {
                result.Pa = await _paService.PerformProtectiveAwardCalculationAsync(data.Pa, options);

                allWeeks.AddRange(result.Pa.PayLines);
            }

            allWeeks.OrderByDescending(x => x.NetEntitlement)
            .ThenByDescending(x => x.GrossEntitlementIn4Months)
            .Take(8)
            .ToList()
            .ForEach(x => x.IsSelected = true);

            return(result);
        }
        public async Task PerformCalculationAsync_PerformsNoCalculationsWhenAPIsEmptyAndPAIsNull()
        {
            // Arrange
            var request = new APPACalculationRequestModel()
            {
                Ap = new List <ArrearsOfPayCalculationRequestModel>(),
                Pa = null
            };

            // Act
            var results = await _service.PerformCalculationAsync(request, _options);

            // Assert
            results.Ap.Should().BeNull();
            results.Pa.Should().BeNull();

            _apService.Verify(m => m.PerformCalculationAsync(
                                  It.IsAny <List <ArrearsOfPayCalculationRequestModel> >(),
                                  It.IsAny <string>(),
                                  It.IsAny <IOptions <ConfigLookupRoot> >(), null), Times.Never);
            _paService.Verify(m => m.PerformProtectiveAwardCalculationAsync(
                                  It.IsAny <ProtectiveAwardCalculationRequestModel>(),
                                  It.IsAny <IOptions <ConfigLookupRoot> >()), Times.Never);
        }
        public async Task PostAsync_Succeeds_WithRP14aDataAndRp1NotRequiredOverride()
        {
            //Arrange
            var request = new APPACalculationRequestModel
            {
                Rp1NotRequired   = true,
                Rp14aNotRequired = false,
                Ap = new List <ArrearsOfPayCalculationRequestModel>()
                {
                    new ArrearsOfPayCalculationRequestModel()
                    {
                        InputSource         = InputSource.Rp14a,
                        InsolvencyDate      = new DateTime(2018, 10, 20),
                        EmploymentStartDate = new DateTime(2016, 04, 06),
                        DismissalDate       = new DateTime(2018, 10, 20),
                        DateNoticeGiven     = new DateTime(2018, 10, 6),
                        UnpaidPeriodFrom    = new DateTime(2018, 10, 1),
                        UnpaidPeriodTo      = new DateTime(2018, 10, 9),
                        ApClaimAmount       = 700M,
                        IsTaxable           = true,
                        PayDay       = 6,
                        ShiftPattern = new List <string> {
                            "1", "2", "3", "4", "5"
                        },
                        WeeklyWage = 400m
                    },
                    new ArrearsOfPayCalculationRequestModel()
                    {
                        InputSource         = InputSource.Rp14a,
                        InsolvencyDate      = new DateTime(2018, 10, 20),
                        EmploymentStartDate = new DateTime(2016, 04, 06),
                        DismissalDate       = new DateTime(2018, 10, 20),
                        DateNoticeGiven     = new DateTime(2018, 10, 14),
                        UnpaidPeriodFrom    = new DateTime(2018, 10, 10),
                        UnpaidPeriodTo      = new DateTime(2018, 10, 18),
                        ApClaimAmount       = 600M,
                        IsTaxable           = true,
                        PayDay       = 6,
                        ShiftPattern = new List <string> {
                            "1", "2", "3", "4", "5"
                        },
                        WeeklyWage = 400m
                    }
                },
                Pa = new ProtectiveAwardCalculationRequestModel()
                {
                    InsolvencyDate           = new DateTime(2018, 10, 20),
                    EmploymentStartDate      = new DateTime(2016, 4, 6),
                    DismissalDate            = new DateTime(2018, 10, 20),
                    TribunalAwardDate        = new DateTime(2018, 10, 21),
                    ProtectiveAwardStartDate = new DateTime(2018, 10, 22),
                    ProtectiveAwardDays      = 90,
                    PayDay       = 6,
                    WeeklyWage   = 400M,
                    ShiftPattern = new List <string> {
                        "1", "2", "3", "4", "5"
                    }
                }
            };
            var response = new APPACalculationResponseDTO();

            _service.Setup(m => m.PerformCalculationAsync(request, _confOptions)).ReturnsAsync(response);
            var controller = new APPAController(_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 PerformCalculationAsync_SelectRp1WhenNoRp14()
        {
            // Arrange
            var shiftPattern = new List <string> {
                "1", "2", "3", "4", "5"
            };

            var apRequests = new List <ArrearsOfPayCalculationRequestModel>()
            {
                new ArrearsOfPayCalculationRequestModel()
                {
                    InputSource         = InputSource.Rp1,
                    InsolvencyDate      = new DateTime(2018, 10, 20),
                    EmploymentStartDate = new DateTime(2016, 04, 06),
                    DismissalDate       = new DateTime(2018, 10, 20),
                    DateNoticeGiven     = new DateTime(2018, 10, 14),
                    UnpaidPeriodFrom    = new DateTime(2018, 10, 10),
                    UnpaidPeriodTo      = new DateTime(2018, 10, 18),
                    ApClaimAmount       = 600M,
                    IsTaxable           = true,
                    PayDay       = 6,
                    ShiftPattern = shiftPattern,
                    WeeklyWage   = 400m
                }
            };

            var apResponseRP1 = new ArrearsOfPayResponseDTO()
            {
                StatutoryMax = 508m,
                InputSource  = InputSource.Rp1,
                DngApplied   = true,
                RunNWNP      = true,
                WeeklyResult = new List <ArrearsOfPayWeeklyResult>()
                {
                    new ArrearsOfPayWeeklyResult(1, new DateTime(2018, 10, 13), 428.57M, 508M, 257.14M, 257.14M, true, 51.43M, 11.42M, 194.29M, 7, 3, 508M, 257.14M, 257.14M),
                    new ArrearsOfPayWeeklyResult(2, new DateTime(2018, 10, 20), 428.57M, 508M, 22.86M, 22.86M, true, 4.57M, 0M, 18.29M, 7, 4, 508M, 22.86M, 22.86M),
                }
            };

            var apResponseRP14a = new ArrearsOfPayResponseDTO()
            {
                StatutoryMax = 508m,
                InputSource  = InputSource.Rp14a,
                DngApplied   = true,
                RunNWNP      = true,
                WeeklyResult = new List <ArrearsOfPayWeeklyResult>()
            };

            var request = new APPACalculationRequestModel()
            {
                Ap = apRequests,
                Pa = null
            };

            _apService.Setup(m => m.PerformCalculationAsync(apRequests, InputSource.Rp1, _options, It.IsAny <TraceInfo>())).ReturnsAsync(apResponseRP1);
            _apService.Setup(m => m.PerformCalculationAsync(apRequests, InputSource.Rp14a, _options, It.IsAny <TraceInfo>())).ReturnsAsync(apResponseRP14a);

            // Act
            var results = await _service.PerformCalculationAsync(request, _options);

            // Assert
            results.Ap.Should().NotBeNull();
            results.Pa.Should().BeNull();

            results.Ap.SelectedInputSource.Should().Be(InputSource.Rp1);
            results.Ap.RP1ResultsList.WeeklyResult.Count.Should().Be(2);
            results.Ap.RP1ResultsList.WeeklyResult.Count(x => x.IsSelected).Should().Be(2);
            results.Ap.RP14aResultsList.WeeklyResult.Count.Should().Be(0);
            results.Ap.RP14aResultsList.WeeklyResult.Count(x => x.IsSelected).Should().Be(0);
        }
        public async Task PerformCalculationAsync_PerformsAPAndPACalculationsWithRp1Selected()
        {
            // Arrange
            var shiftPattern = new List <string> {
                "1", "2", "3", "4", "5"
            };

            var apRequests = new List <ArrearsOfPayCalculationRequestModel>()
            {
                new ArrearsOfPayCalculationRequestModel()
                {
                    InputSource         = InputSource.Rp1,
                    InsolvencyDate      = new DateTime(2018, 10, 20),
                    EmploymentStartDate = new DateTime(2016, 04, 06),
                    DismissalDate       = new DateTime(2018, 10, 20),
                    DateNoticeGiven     = new DateTime(2018, 10, 6),
                    UnpaidPeriodFrom    = new DateTime(2018, 10, 1),
                    UnpaidPeriodTo      = new DateTime(2018, 10, 9),
                    ApClaimAmount       = 350M,
                    IsTaxable           = true,
                    PayDay       = 6,
                    ShiftPattern = shiftPattern,
                    WeeklyWage   = 200m
                },
                new ArrearsOfPayCalculationRequestModel()
                {
                    InputSource         = InputSource.Rp14a,
                    InsolvencyDate      = new DateTime(2018, 10, 20),
                    EmploymentStartDate = new DateTime(2016, 04, 06),
                    DismissalDate       = new DateTime(2018, 10, 20),
                    DateNoticeGiven     = new DateTime(2018, 10, 14),
                    UnpaidPeriodFrom    = new DateTime(2018, 10, 10),
                    UnpaidPeriodTo      = new DateTime(2018, 10, 18),
                    ApClaimAmount       = 600M,
                    IsTaxable           = true,
                    PayDay       = 6,
                    ShiftPattern = shiftPattern,
                    WeeklyWage   = 400m
                }
            };

            var apResponseRP1 = new ArrearsOfPayResponseDTO()
            {
                StatutoryMax = 508m,
                InputSource  = InputSource.Rp1,
                DngApplied   = true,
                RunNWNP      = false,
                WeeklyResult = new List <ArrearsOfPayWeeklyResult>()
                {
                    new ArrearsOfPayWeeklyResult(1, new DateTime(2018, 10, 6), 250m, 508M, 350, 350M, true, 50M, 30M, 300M, 7, 5, 508M, 300M, 300M),
                    new ArrearsOfPayWeeklyResult(2, new DateTime(2018, 10, 13), 250m, 508M, 20M, 20M, true, 4M, 0M, 16M, 7, 2, 508M, 20M, 20M),
                }
            };

            var apResponseRP14a = new ArrearsOfPayResponseDTO()
            {
                StatutoryMax = 508m,
                InputSource  = InputSource.Rp14a,
                DngApplied   = true,
                RunNWNP      = true,
                WeeklyResult = new List <ArrearsOfPayWeeklyResult>()
                {
                    new ArrearsOfPayWeeklyResult(1, new DateTime(2018, 10, 13), 428.57M, 508M, 257.14M, 357.14M, true, 51.43M, 11.42M, 294.29M, 7, 3, 508M, 357.14M, 357.14M),
                    new ArrearsOfPayWeeklyResult(2, new DateTime(2018, 10, 20), 428.57M, 508M, 22.86M, 22.86M, true, 4.57M, 0M, 28.29M, 7, 4, 508M, 22.86M, 22.86M),
                }
            };

            var paRequest = new ProtectiveAwardCalculationRequestModel()
            {
                InsolvencyDate           = new DateTime(2018, 10, 20),
                EmploymentStartDate      = new DateTime(2016, 4, 6),
                DismissalDate            = new DateTime(2018, 10, 20),
                TribunalAwardDate        = new DateTime(2018, 10, 21),
                ProtectiveAwardStartDate = new DateTime(2018, 10, 22),
                ProtectiveAwardDays      = 90,
                PayDay       = 6,
                WeeklyWage   = 400M,
                ShiftPattern = shiftPattern,
            };

            var paResponse = new ProtectiveAwardResponseDTO()
            {
                IsTaxable    = true,
                StatutoryMax = 508m,
                PayLines     = new List <ProtectiveAwardPayLine>()
                {
                    new ProtectiveAwardPayLine(1, new DateTime(2018, 10, 27), 0M, 400M, 80M, 28.56M, 291.44M, 0M, 0M, 0M),
                    new ProtectiveAwardPayLine(2, new DateTime(2018, 11, 3), 0M, 400M, 80M, 28.56M, 291.44M, 0M, 0M, 0M),
                    new ProtectiveAwardPayLine(3, new DateTime(2018, 11, 10), 0M, 400M, 80M, 28.56M, 291.44M, 0M, 0M, 0M),
                    new ProtectiveAwardPayLine(4, new DateTime(2018, 11, 17), 0M, 400M, 80M, 28.56M, 291.44M, 0M, 0M, 0M),
                    new ProtectiveAwardPayLine(5, new DateTime(2018, 11, 24), 0M, 400M, 80M, 28.56M, 291.44M, 0M, 0M, 0M),
                    new ProtectiveAwardPayLine(6, new DateTime(2018, 12, 1), 0M, 400M, 80M, 28.56M, 291.44M, 0M, 0M, 0M),
                    new ProtectiveAwardPayLine(7, new DateTime(2018, 12, 8), 0M, 400M, 80M, 28.56M, 291.44M, 0M, 0M, 0M),
                    new ProtectiveAwardPayLine(8, new DateTime(2018, 12, 15), 0M, 400M, 80M, 28.56M, 291.44M, 0M, 0M, 0M),
                    new ProtectiveAwardPayLine(9, new DateTime(2018, 12, 22), 0M, 400M, 80M, 28.56M, 291.44M, 0M, 0M, 0M),
                    new ProtectiveAwardPayLine(10, new DateTime(2018, 12, 29), 0M, 400M, 80M, 28.56M, 291.44M, 0M, 0M, 0M),
                    new ProtectiveAwardPayLine(11, new DateTime(2019, 1, 5), 0M, 400M, 80M, 28.56M, 291.44M, 0M, 0M, 0M),
                    new ProtectiveAwardPayLine(12, new DateTime(2019, 1, 12), 0M, 400M, 80M, 28.56M, 291.44M, 0M, 0M, 0M),
                    new ProtectiveAwardPayLine(13, new DateTime(2019, 1, 12), 0M, 400M, 80M, 28.56M, 291.44M, 0M, 0M, 0M)
                }
            };

            var request = new APPACalculationRequestModel()
            {
                Ap = apRequests,
                Pa = paRequest
            };

            _apService.Setup(m => m.PerformCalculationAsync(apRequests, InputSource.Rp1, _options, It.IsAny <TraceInfo>())).ReturnsAsync(apResponseRP1);
            _apService.Setup(m => m.PerformCalculationAsync(apRequests, InputSource.Rp14a, _options, It.IsAny <TraceInfo>())).ReturnsAsync(apResponseRP14a);
            _paService.Setup(m => m.PerformProtectiveAwardCalculationAsync(paRequest, _options)).ReturnsAsync(paResponse);

            // Act
            var results = await _service.PerformCalculationAsync(request, _options);

            // Assert
            results.Ap.Should().NotBeNull();
            results.Pa.Should().NotBeNull();

            results.Ap.SelectedInputSource.Should().Be(InputSource.Rp1);
            results.Ap.RP1ResultsList.WeeklyResult.Count(x => x.IsSelected).Should().Be(1);
            results.Ap.RP14aResultsList.WeeklyResult.Count(x => x.IsSelected).Should().Be(0);
            results.Pa.PayLines.Count(x => x.IsSelected).Should().Be(7);
        }