Пример #1
0
        public async Task GivenTheApprenticeshipsStatusChangesAsFollows(Table table)
        {
            var statuses      = table.CreateSet <ApprenticeshipStatusPeriod>();
            var validStatuses = statuses.Select(status => new
            {
                status.Status,
                CollectionPeriod = new CollectionPeriodBuilder().WithSpecDate(status.CollectionPeriod).Build(),
                status.Identifier,
                status.StoppedDate
            })
                                .Where(status => status.CollectionPeriod.AcademicYear == CurrentCollectionPeriod.AcademicYear &&
                                       status.CollectionPeriod.Period == CurrentCollectionPeriod.Period)
                                .ToList();

            foreach (var validStatus in validStatuses)
            {
                var apprenticeship = Apprenticeships.FirstOrDefault(appr => appr.Identifier == validStatus.Identifier);
                if (apprenticeship == null)
                {
                    throw new InvalidOperationException($"Apprenticeship not found. Identifier: {validStatus.Identifier}");
                }
                Console.WriteLine($"Updating status of apprenticeship. Identifier: {validStatus.Identifier}, apprenticeship id: {apprenticeship.ApprenticeshipId}, status: {validStatus.Status}");
                await UpdateApprenticeshipStatus(apprenticeship.ApprenticeshipId, validStatus.Status, validStatus.StoppedDate);
            }
        }
Пример #2
0
        private async Task ValidateDataLockError(Table table, Provider provider)
        {
            var dataLockErrors = table.CreateSet <DataLockError>().ToList();

            foreach (var dataLockError in dataLockErrors)
            {
                if (string.IsNullOrWhiteSpace(dataLockError.Apprenticeship))
                {
                    continue;
                }

                var apprenticeship = Apprenticeships.FirstOrDefault(a => a.Identifier == dataLockError.Apprenticeship) ??
                                     throw new Exception($"Can't find a matching apprenticeship for Identifier {dataLockError.Apprenticeship}");

                dataLockError.ApprenticeshipId = apprenticeship.ApprenticeshipId;
            }

            var matcher = new EarningFailedDataLockMatcher(provider, TestSession, CurrentCollectionPeriod, dataLockErrors);

            await WaitForIt(() => matcher.MatchPayments(), "DataLock Failed event check failure");
        }