Esempio n. 1
0
        public void ValidCommitmentsShouldBeCommitmentsThatStartOnOrBeforePriceEpisode(
            List <ApprenticeshipModel> apprenticeshipModels, PriceEpisode priceEpisode)
        {
            priceEpisode.EffectiveTotalNegotiatedPriceStartDate = new DateTime(2018, 8, 1);

            apprenticeshipModels[0].ApprenticeshipPriceEpisodes[0].StartDate = new DateTime(2018, 6, 1);
            apprenticeshipModels[0].ApprenticeshipPriceEpisodes[0].EndDate   = new DateTime(2018, 8, 1);
            apprenticeshipModels[0].ApprenticeshipPriceEpisodes[0].Removed   = false;
            apprenticeshipModels[0].ApprenticeshipPriceEpisodes.RemoveRange(1, 2);

            apprenticeshipModels[1].ApprenticeshipPriceEpisodes[0].StartDate = new DateTime(2018, 8, 1);
            apprenticeshipModels[1].ApprenticeshipPriceEpisodes[0].EndDate   = new DateTime(2019, 8, 30);
            apprenticeshipModels[1].ApprenticeshipPriceEpisodes[0].Removed   = false;
            apprenticeshipModels[1].ApprenticeshipPriceEpisodes.RemoveRange(1, 2);

            apprenticeshipModels[2].ApprenticeshipPriceEpisodes[0].StartDate = new DateTime(2019, 9, 1);
            apprenticeshipModels[2].ApprenticeshipPriceEpisodes[0].EndDate   = new DateTime(2020, 9, 30);
            apprenticeshipModels[2].ApprenticeshipPriceEpisodes[0].Removed   = false;
            apprenticeshipModels[2].ApprenticeshipPriceEpisodes.RemoveRange(1, 2);

            var validator = new StartDateValidator(false);
            var result    = validator.Validate(priceEpisode, apprenticeshipModels);

            result.dataLockFailures.Should().BeEmpty();
            result.validApprenticeships.Should().HaveCount(2);
            result.validApprenticeships.Any(x => x.Id == apprenticeshipModels[0].Id).Should().BeTrue();
            result.validApprenticeships.Any(x => x.Id == apprenticeshipModels[1].Id).Should().BeTrue();
        }
        public void ReturnsMatchedPriceEpisodes()
        {
            var validation = new DataLockValidationModel
            {
                PriceEpisode = new PriceEpisode {
                    EffectiveTotalNegotiatedPriceStartDate = startDate, Identifier = priceEpisodeIdentifier
                },
                EarningPeriod  = period,
                Apprenticeship = new ApprenticeshipModel
                {
                    Id = 1,
                    ApprenticeshipPriceEpisodes = new List <ApprenticeshipPriceEpisodeModel>
                    {
                        new ApprenticeshipPriceEpisodeModel
                        {
                            Id        = 99,
                            StartDate = startDate.AddDays(-1)
                        }
                    }
                }
            };

            var validator = new StartDateValidator(calculatePeriodStartAndEndDate.Object);
            var result    = validator.Validate(validation);

            result.DataLockErrorCode.Should().BeNull();
            result.ApprenticeshipPriceEpisodes.Any(ape => ape.Id == 99).Should().BeTrue();
        }
        public void ShouldNotMatchRemovedApprenticeshipPriceEpisodes()
        {
            var validation = new DataLockValidationModel
            {
                PriceEpisode = new PriceEpisode {
                    EffectiveTotalNegotiatedPriceStartDate = startDate, Identifier = priceEpisodeIdentifier
                },
                EarningPeriod  = period,
                Apprenticeship = new ApprenticeshipModel
                {
                    Id = 1,
                    ApprenticeshipPriceEpisodes = new List <ApprenticeshipPriceEpisodeModel>
                    {
                        new ApprenticeshipPriceEpisodeModel
                        {
                            StartDate = startDate.AddDays(-1),
                            Removed   = true
                        }
                    }
                }
            };

            var validator = new StartDateValidator(calculatePeriodStartAndEndDate.Object);
            var result    = validator.Validate(validation);

            result.DataLockErrorCode.Should().NotBeNull();
            result.DataLockErrorCode.Should().Be(DataLockErrorCode.DLOCK_09);
        }
Esempio n. 4
0
        public void ReturnsAllCommitmentsWhenDisableDatalocksAreOn(ApprenticeshipModel apprenticeshipA, ApprenticeshipModel apprenticeshipB, PriceEpisode priceEpisode)
        {
            priceEpisode.EffectiveTotalNegotiatedPriceStartDate = new DateTime(1930, 8, 1);
            var apprenticeshipModels = new List <ApprenticeshipModel> {
                apprenticeshipA, apprenticeshipB
            };

            var validator = new StartDateValidator(true);
            var result    = validator.Validate(priceEpisode, apprenticeshipModels);

            result.validApprenticeships.Should().BeEquivalentTo(apprenticeshipModels);
        }
        public void ApprenticeshipsNotWithinADeliveryPeriodShouldReturnDLock09()
        {
            period = new EarningPeriod
            {
                Period = 1
            };

            var validation = new DataLockValidationModel
            {
                PriceEpisode = new PriceEpisode
                {
                    EffectiveTotalNegotiatedPriceStartDate = startDate,
                    Identifier = priceEpisodeIdentifier
                },
                EarningPeriod  = period,
                Apprenticeship = new ApprenticeshipModel
                {
                    Id        = 1,
                    AccountId = 21,
                    ApprenticeshipPriceEpisodes = new List <ApprenticeshipPriceEpisodeModel>
                    {
                        new ApprenticeshipPriceEpisodeModel {
                            Id = 90
                        },
                        new ApprenticeshipPriceEpisodeModel {
                            Id = 91
                        },
                        new ApprenticeshipPriceEpisodeModel {
                            Id = 92
                        },
                        new ApprenticeshipPriceEpisodeModel {
                            Id = 93
                        },
                    },
                    EstimatedStartDate = new DateTime(2018, 9, 15)
                }
            };

            calculatePeriodStartAndEndDate
            .Setup(x => x.GetPeriodDate(1, 1819))
            .Returns(() => (new DateTime(2018, 8, 1), new DateTime(2018, 8, 31)));


            var validator = new StartDateValidator(calculatePeriodStartAndEndDate.Object);
            var result    = validator.Validate(validation);

            result.DataLockErrorCode.Should().NotBeNull();
            result.DataLockErrorCode.Should().Be(DataLockErrorCode.DLOCK_09);
            result.ApprenticeshipPriceEpisodes.Should().BeEmpty();
        }
        public void AssignsAllValidPriceEpisodes()
        {
            var validation = new DataLockValidationModel
            {
                PriceEpisode = new PriceEpisode {
                    EffectiveTotalNegotiatedPriceStartDate = startDate, Identifier = priceEpisodeIdentifier
                },
                EarningPeriod  = period,
                Apprenticeship = new ApprenticeshipModel
                {
                    Id = 1,
                    ApprenticeshipPriceEpisodes = new List <ApprenticeshipPriceEpisodeModel>
                    {
                        new ApprenticeshipPriceEpisodeModel
                        {
                            Id        = 1,
                            StartDate = startDate.AddDays(-6),
                            EndDate   = startDate.AddDays(-5),
                        },
                        new ApprenticeshipPriceEpisodeModel
                        {
                            Id        = 2,
                            StartDate = startDate.AddDays(-2),
                            EndDate   = startDate.AddDays(-1)
                        },
                        new ApprenticeshipPriceEpisodeModel
                        {
                            Id        = 3,
                            StartDate = startDate
                        },
                        new ApprenticeshipPriceEpisodeModel
                        {
                            Id        = 4,
                            StartDate = startDate.AddDays(-4),
                            EndDate   = startDate.AddDays(-3),
                        },
                    }
                }
            };

            var validator = new StartDateValidator(calculatePeriodStartAndEndDate.Object);
            var result    = validator.Validate(validation);

            result.DataLockErrorCode.Should().BeNull();
            result.ApprenticeshipPriceEpisodes[0].Id.Should().Be(1);
            result.ApprenticeshipPriceEpisodes[1].Id.Should().Be(2);
            result.ApprenticeshipPriceEpisodes[2].Id.Should().Be(3);
            result.ApprenticeshipPriceEpisodes[3].Id.Should().Be(4);
        }
Esempio n. 7
0
        public void ReturnsDLock09WhenNoCommitmentsStartOnOrBeforePriceEpisode(ApprenticeshipModel apprenticeshipA, ApprenticeshipModel apprenticeshipB, PriceEpisode priceEpisode)
        {
            priceEpisode.EffectiveTotalNegotiatedPriceStartDate = new DateTime(2018, 8, 1);

            apprenticeshipA.ApprenticeshipPriceEpisodes.ForEach(x => x.Removed = true);
            apprenticeshipA.ApprenticeshipPriceEpisodes[0].StartDate           = new DateTime(2018, 9, 1);
            apprenticeshipA.ApprenticeshipPriceEpisodes[0].EndDate             = new DateTime(2019, 9, 30);
            apprenticeshipA.ApprenticeshipPriceEpisodes[0].Removed             = false;

            apprenticeshipB.ApprenticeshipPriceEpisodes.ForEach(x => x.Removed = true);
            apprenticeshipB.ApprenticeshipPriceEpisodes[0].StartDate           = new DateTime(2019, 9, 1);
            apprenticeshipB.ApprenticeshipPriceEpisodes[0].EndDate             = new DateTime(2020, 9, 30);
            apprenticeshipB.ApprenticeshipPriceEpisodes[0].Removed             = false;

            List <ApprenticeshipModel> apprenticeshipModels = new List <ApprenticeshipModel> {
                apprenticeshipA, apprenticeshipB
            };

            var validator = new StartDateValidator(false);
            var result    = validator.Validate(priceEpisode, apprenticeshipModels);

            result.validApprenticeships.Should().BeEmpty();
            result.dataLockFailures.Should().HaveCount(2);
            result.dataLockFailures.Should().ContainEquivalentOf(
                new
            {
                ApprenticeshipId = apprenticeshipA.Id,
                ApprenticeshipPriceEpisodeIds = new List <long>()
                {
                    apprenticeshipA.ApprenticeshipPriceEpisodes[0].Id
                },
                DataLockError = DataLockErrorCode.DLOCK_09,
            });

            result.dataLockFailures.Should().ContainEquivalentOf(
                new
            {
                ApprenticeshipId = apprenticeshipB.Id,
                ApprenticeshipPriceEpisodeIds = new List <long>()
                {
                    apprenticeshipB.ApprenticeshipPriceEpisodes[0].Id
                },
                DataLockError = DataLockErrorCode.DLOCK_09,
            });
        }