Example #1
0
 protected override void SetupDatabase()
 {
     EventTestsRepository = new EventTestsRepository(DataAcceptanceTests.Config.DatabaseConnectionString);
     EventTestsRepository.DeleteProviders().Wait();
     EventTestsRepository.DeleteFailedEvents().Wait();
     EventTestsRepository.StoreLastProcessedEventId(EventName, 2).Wait();
 }
        public async Task ThenTheTransfersAreStored()
        {
            // arrange
            var expectedTransfers       = ConfigureEventsApi().OrderBy(t => t.TransferId).ToList();
            var cancellationTokenSource = new CancellationTokenSource();
            var cancellationToken       = cancellationTokenSource.Token;

            // act
            Task.Run(() => WorkerRole.Run(), cancellationToken);
            var periodEndFinished = TestHelper.ConditionMet(PeriodEndProcessed, TimeSpan.FromSeconds(60));

            cancellationTokenSource.Cancel();

            // assert
            Assert.IsTrue(periodEndFinished);

            var actualTransfers = (await EventTestsRepository.GetTransfers()).OrderBy(t => t.TransferId).ToList();

            Assert.AreEqual(expectedTransfers.Count, actualTransfers.Count);

            for (var i = 0; i < actualTransfers.Count; i++)
            {
                Assert.AreEqual(expectedTransfers[i].TransferId, actualTransfers[i].TransferId);
                Assert.AreEqual(expectedTransfers[i].Amount, actualTransfers[i].Amount);
                Assert.AreEqual(expectedTransfers[i].SenderAccountId, actualTransfers[i].SenderAccountId);
                Assert.AreEqual(expectedTransfers[i].ReceiverAccountId, actualTransfers[i].ReceiverAccountId);
                Assert.AreEqual(expectedTransfers[i].RequiredPaymentId, actualTransfers[i].RequiredPaymentId);
                Assert.AreEqual(expectedTransfers[i].Type, actualTransfers[i].Type);
                Assert.AreEqual(expectedTransfers[i].CommitmentId, actualTransfers[i].CommitmentId);
                Assert.AreEqual(expectedTransfers[i].CollectionPeriodName, actualTransfers[i].CollectionPeriodName);
            }
        }
Example #3
0
 protected override void SetupDatabase()
 {
     EventTestsRepository = new EventTestsRepository(DataAcceptanceTests.Config.DatabaseConnectionString);
     EventTestsRepository.DeleteApprenticeships().Wait();
     EventTestsRepository.DeleteFailedEvents().Wait();
     EventTestsRepository.StoreLastProcessedEventId("ApprenticeshipEventView", 2).Wait();
 }
Example #4
0
        private async Task <bool> IsDatabaseInExpectedState()
        {
            var lastProcessedEventId = await EventTestsRepository.GetLastProcessedEventId <long>(EventName);

            if (lastProcessedEventId != 4)
            {
                return(false);
            }

            var numberOfRegistrations = await EventTestsRepository.GetNumberOfAccounts();

            if (numberOfRegistrations != 2)
            {
                return(false);
            }

            var numberOfLegalEntities = await EventTestsRepository.GetNumberOfLegalEntities();

            if (numberOfLegalEntities != 3)
            {
                return(false);
            }

            var numberOfPayeSchemes = await EventTestsRepository.GetNumberOfPayeSchemes();

            if (numberOfPayeSchemes != 3)
            {
                return(false);
            }

            return(true);
        }
        private async Task <bool> IsDatabaseInExpectedState()
        {
            var lastProcessedEventId = await EventTestsRepository.GetLastProcessedEventId <string>(EventName);

            if (lastProcessedEventId != "3")
            {
                return(false);
            }

            var numberOfDataLockEvents = await EventTestsRepository.GetNumberOfDataLockEvents();

            if (numberOfDataLockEvents != 3)
            {
                return(false);
            }

            var numberOfDataLockErrors = await EventTestsRepository.GetNumberOfDataLockErrors();

            if (numberOfDataLockErrors != 6)
            {
                return(false);
            }

            return(true);
        }
Example #6
0
 protected override void SetupDatabase()
 {
     EventTestsRepository = new EventTestsRepository(DataAcceptanceTests.Config.DatabaseConnectionString);
     EventTestsRepository.DeleteEmploymentChecks().Wait();
     EventTestsRepository.DeleteFailedEvents().Wait();
     EventTestsRepository.StoreLastProcessedEventId("EmploymentCheckCompleteEvent", 2).Wait();
 }
Example #7
0
 protected override void SetupDatabase()
 {
     EventTestsRepository = new EventTestsRepository(DataAcceptanceTests.Config.DatabaseConnectionString);
     EventTestsRepository.DeletePayments().Wait();
     EventTestsRepository.DeleteTransfers().Wait();
     EventTestsRepository.StoreLastProcessedEventId("PeriodEnd-Payment", "PERIOD2").Wait();
     EventTestsRepository.StoreLastProcessedEventId("PeriodEnd-AccountTransfer", "PERIOD2").Wait();
 }
Example #8
0
 protected override void SetupDatabase()
 {
     EventTestsRepository = new EventTestsRepository(DataAcceptanceTests.Config.DatabaseConnectionString);
     EventTestsRepository.DeleteAccounts().Wait();
     EventTestsRepository.DeleteLevyDeclarations().Wait();
     EventTestsRepository.DeleteEmployerAgreements().Wait();
     EventTestsRepository.DeleteFailedEvents().Wait();
     EventTestsRepository.StoreLastProcessedEventId(EventName, 2).Wait();
 }
Example #9
0
        private async Task<bool> IsDatabaseInExpectedState()
        {
            var lastProcessedEventId = await EventTestsRepository.GetLastProcessedEventId<long>(EventName);
            if (lastProcessedEventId != 4)
            {
                return false;
            }

            var numberOfAccounts = await EventTestsRepository.GetNumberOfAccounts();
            if (numberOfAccounts != 2)
            {
                return false;
            }

            return true;
        }
        private async Task AreDataLockFieldsStoredCorrectly(IList <DataLockEvent> expectedDataLockEvents)
        {
            var actualDataLocks      = (await EventTestsRepository.GetDataLocks()).OrderBy(d => d.DataLockId).ToList();
            var actualDataLockErrors = (await EventTestsRepository.GetDataLockErrors()).OrderBy(e => e.DataLockId).ThenBy(e => e.ErrorCode).ToList();

            for (var i = 0; i < actualDataLocks.Count; i++)
            {
                Assert.AreEqual(expectedDataLockEvents[i].Id, actualDataLocks[i].DataLockId);

                var expectedDataLock = expectedDataLockEvents[i];
                var actualDataLock   = actualDataLocks[i];

                Assert.AreEqual(expectedDataLock.ProcessDateTime, actualDataLock.ProcessDateTime);
                Assert.AreEqual(expectedDataLock.Status, actualDataLock.Status);
                Assert.AreEqual(expectedDataLock.IlrFileName, actualDataLock.IlrFileName);
                Assert.AreEqual(expectedDataLock.Ukprn, actualDataLock.UkPrn);
                Assert.AreEqual(expectedDataLock.Uln, actualDataLock.Uln);
                Assert.AreEqual(expectedDataLock.LearnRefNumber, actualDataLock.LearnRefNumber);
                Assert.AreEqual(expectedDataLock.AimSeqNumber, actualDataLock.AimSeqNumber);
                Assert.AreEqual(expectedDataLock.PriceEpisodeIdentifier, actualDataLock.PriceEpisodeIdentifier);
                Assert.AreEqual(expectedDataLock.ApprenticeshipId, actualDataLock.ApprenticeshipId);
                Assert.AreEqual(expectedDataLock.EmployerAccountId, actualDataLock.EmployerAccountId);
                Assert.AreEqual(expectedDataLock.EventSource, actualDataLock.EventSource);
                Assert.AreEqual(expectedDataLock.IlrStartDate, actualDataLock.IlrStartDate);
                Assert.AreEqual(expectedDataLock.IlrStandardCode, actualDataLock.IlrStandardCode);
                Assert.AreEqual(expectedDataLock.IlrProgrammeType, actualDataLock.IlrProgrammeType);
                Assert.AreEqual(expectedDataLock.IlrFrameworkCode, actualDataLock.IlrFrameworkCode);
                Assert.AreEqual(expectedDataLock.IlrPathwayCode, actualDataLock.IlrPathwayCode);
                Assert.AreEqual(expectedDataLock.IlrTrainingPrice, actualDataLock.IlrTrainingPrice);
                Assert.AreEqual(expectedDataLock.IlrEndpointAssessorPrice, actualDataLock.IlrEndpointAssessorPrice);
                Assert.AreEqual(expectedDataLock.IlrPriceEffectiveFromDate, actualDataLock.IlrPriceEffectiveFromDate);
                Assert.AreEqual(expectedDataLock.IlrPriceEffectiveToDate, actualDataLock.IlrPriceEffectiveToDate);
                Assert.AreEqual(true, actualDataLock.IsLatest);

                //Check errors
                var actualErrors = actualDataLockErrors.Where(e => e.DataLockId == actualDataLock.Id).OrderBy(e => e.ErrorCode)
                                   .ToList();
                Assert.AreEqual(expectedDataLock.Errors.Length, actualErrors.Count);
                foreach (var expectedError in expectedDataLock.Errors)
                {
                    var actualError = actualErrors.SingleOrDefault(e => e.ErrorCode == expectedError.ErrorCode);
                    Assert.IsNotNull(actualError);
                    Assert.AreEqual(expectedError.SystemDescription, actualError.SystemDescription);
                }
            }
        }
Example #11
0
        private async Task <bool> IsDatabaseInExpectedState()
        {
            var lastProcessedEventId = await EventTestsRepository.GetLastProcessedEventId <long>("ApprenticeshipEventView");

            if (lastProcessedEventId != 4)
            {
                return(false);
            }

            var numberOfRegistrations = await EventTestsRepository.GetNumberOfApprenticeships();

            if (numberOfRegistrations != 2)
            {
                return(false);
            }

            return(true);
        }
        private async Task <bool> IsDatabaseInExpectedState()
        {
            var lastProcessedEventId = await EventTestsRepository.GetLastProcessedEventId <long>(EventName);

            if (lastProcessedEventId != 4)
            {
                return(false);
            }

            var numberOfLevyDeclarations = await EventTestsRepository.GetNumberOfLevyDeclarations();

            if (numberOfLevyDeclarations != 3)
            {
                return(false);
            }

            return(true);
        }
Example #13
0
        private async Task <bool> IsDatabaseInExpectedState()
        {
            var lastProcessedEventId = await EventTestsRepository.GetLastProcessedEventId <string>("PeriodEnd-Payment");

            if (lastProcessedEventId != "PERIOD4")
            {
                return(false);
            }

            var numberOfPayments = await EventTestsRepository.GetNumberOfPayments();

            if (numberOfPayments != 7)
            {
                return(false);
            }

            return(true);
        }
Example #14
0
        private async Task <bool> IsDatabaseInExpectedState()
        {
            var lastProcessedEventId = await EventTestsRepository.GetLastProcessedEventId <long>("EmploymentCheckCompleteEvent");

            if (lastProcessedEventId != 4)
            {
                return(false);
            }

            var numberOfEmploymentChecks = await EventTestsRepository.GetNumberOfEmploymentChecks();

            if (numberOfEmploymentChecks != 2)
            {
                return(false);
            }

            return(true);
        }
        public async Task AndThereAreALotOfTransfersThenTheyAreProcessedInPages(bool skipPayments)
        {
            // skipPayments will generate error on parallel processing of payments, this should not affect transfers processing

            // arrange
            var expectedTransfers       = ConfigureEventsApi(3, skipPayments).OrderBy(t => t.TransferId).ToList();
            var cancellationTokenSource = new CancellationTokenSource();
            var cancellationToken       = cancellationTokenSource.Token;

            // act
            Task.Run(() => WorkerRole.Run(), cancellationToken);
            var periodEndFinished = TestHelper.ConditionMet(PeriodEndProcessed, TimeSpan.FromSeconds(60));

            cancellationTokenSource.Cancel();

            // assert
            Assert.IsTrue(periodEndFinished);

            var actualCount = await EventTestsRepository.GetNumberOfTransfers();

            Assert.AreEqual(expectedTransfers.Count, actualCount);
        }
Example #16
0
 protected override void SetupDatabase()
 {
     EventTestsRepository = new EventTestsRepository(DataAcceptanceTests.Config.DatabaseConnectionString);
     EventTestsRepository.DeleteDataLocks().Wait();
     EventTestsRepository.StoreLastProcessedEventId(typeof(DataLockEvent).Name, "0").Wait();
 }
 private async Task <bool> PeriodEndProcessed()
 {
     return(await EventTestsRepository.GetLastProcessedEventId <string>("PeriodEnd-AccountTransfer") == "PERIOD4");
 }