Esempio n. 1
0
        public void Arrange()
        {
            var today = new DateTime(2021, 1, 30);

            _fixture = new Fixture();

            _mockPaymentProfilesService     = new Mock <IIncentivePaymentProfilesService>();
            _mockIncentiveDomainRespository = new Mock <IApprenticeshipIncentiveDomainRepository>();
            _mockCollectionCalendarService  = new Mock <ICollectionCalendarService>();

            _paymentProfiles = new List <IncentivePaymentProfile>
            {
                new IncentivePaymentProfile(
                    IncentiveType.TwentyFiveOrOverIncentive, new List <PaymentProfile>
                {
                    new PaymentProfile(10, 100),
                    new PaymentProfile(100, 1000)
                })
            };

            _mockPaymentProfilesService
            .Setup(m => m.Get())
            .ReturnsAsync(_paymentProfiles);

            _collectionPeriods = new List <Domain.ValueObjects.CollectionPeriod>()
            {
                new Domain.ValueObjects.CollectionPeriod(1, (byte)today.Month, (short)today.Year, today.AddDays(-1), _fixture.Create <DateTime>(), _fixture.Create <short>(), false)
            };

            _mockCollectionCalendarService
            .Setup(m => m.Get())
            .ReturnsAsync(new Domain.ValueObjects.CollectionCalendar(_collectionPeriods));

            var incentive = new ApprenticeshipIncentiveFactory()
                            .CreateNew(_fixture.Create <Guid>(),
                                       _fixture.Create <Guid>(),
                                       _fixture.Create <Account>(),
                                       new Apprenticeship(
                                           _fixture.Create <long>(),
                                           _fixture.Create <string>(),
                                           _fixture.Create <string>(),
                                           today.AddYears(-26),
                                           _fixture.Create <long>(),
                                           ApprenticeshipEmployerType.Levy,
                                           _fixture.Create <string>()
                                           ),
                                       today,
                                       _fixture.Create <DateTime>(),
                                       _fixture.Create <string>());

            incentive.Apprenticeship.SetProvider(_fixture.Create <Provider>());

            _fixture.Register(() => incentive);

            _sut = new CalculateEarningsCommandHandler(
                _mockIncentiveDomainRespository.Object,
                _mockPaymentProfilesService.Object,
                _mockCollectionCalendarService.Object);
        }
        public void Arrange()
        {
            var today = new DateTime(2021, 1, 30);

            _fixture = new Fixture();

            _mockPaymentProfilesService     = new Mock <IIncentivePaymentProfilesService>();
            _mockIncentiveDomainRespository = new Mock <IApprenticeshipIncentiveDomainRepository>();
            _mockCollectionCalendarService  = new Mock <ICollectionCalendarService>();

            _paymentProfiles = new IncentivePaymentProfileListBuilder().Build();

            _mockPaymentProfilesService
            .Setup(m => m.Get())
            .ReturnsAsync(_paymentProfiles);

            _collectionPeriods = new List <CollectionCalendarPeriod>()
            {
                new CollectionCalendarPeriod(new Domain.ValueObjects.CollectionPeriod(1, _fixture.Create <short>()), (byte)today.Month, (short)today.Year, today.AddDays(-1), _fixture.Create <DateTime>(), true, false)
            };

            _mockCollectionCalendarService
            .Setup(m => m.Get())
            .ReturnsAsync(new Domain.ValueObjects.CollectionCalendar(_collectionPeriods));

            var incentive = new ApprenticeshipIncentiveFactory()
                            .CreateNew(_fixture.Create <Guid>(),
                                       _fixture.Create <Guid>(),
                                       _fixture.Create <Account>(),
                                       new Apprenticeship(
                                           _fixture.Create <long>(),
                                           _fixture.Create <string>(),
                                           _fixture.Create <string>(),
                                           today.AddYears(-26),
                                           _fixture.Create <long>(),
                                           ApprenticeshipEmployerType.Levy,
                                           _fixture.Create <string>(),
                                           _fixture.Create <DateTime>()
                                           ),
                                       today,
                                       _fixture.Create <DateTime>(),
                                       _fixture.Create <string>(),
                                       new AgreementVersion(_fixture.Create <int>()),
                                       new IncentivePhase(Phase.Phase1));

            incentive.Apprenticeship.SetProvider(_fixture.Create <Provider>());

            _fixture.Register(() => incentive);

            _mockCommandPublisher = new Mock <IScheduledCommandPublisher>();

            _sut = new CalculateEarningsCommandHandler(
                _mockIncentiveDomainRespository.Object,
                _mockPaymentProfilesService.Object,
                _mockCollectionCalendarService.Object,
                _mockCommandPublisher.Object);
        }