public void Cleanup()
        {
            foreach (var cata in CatalogueRepository.GetAllObjects <Catalogue>().Where(c => c.Name.Equals(BulkTestsData.BulkDataTable)))
            {
                cata.DeleteInDatabase();
            }

            foreach (TableInfo toCleanup in CatalogueRepository.GetAllObjects <TableInfo>().Where(t => t.GetRuntimeName().Equals(BulkTestsData.BulkDataTable)))
            {
                foreach (PreLoadDiscardedColumn column in toCleanup.PreLoadDiscardedColumns)
                {
                    column.DeleteInDatabase();
                }


                var credentials = (DataAccessCredentials)toCleanup.GetCredentialsIfExists(DataAccessContext.InternalDataProcessing);
                toCleanup.DeleteInDatabase();

                if (credentials != null)
                {
                    try
                    {
                        credentials.DeleteInDatabase();
                    }
                    catch (CredentialsInUseException e)
                    {
                        Console.WriteLine("Ignored credentials in use exception :" + e);
                    }
                }
            }

            if (_bulkData != null)
            {
                _bulkData.Destroy();
            }
        }
Beispiel #2
0
        public void ValidateBulkTestData(bool testCancellingValiationEarly)
        {
            int      numberOfRecordsToGenerate = 10000;
            DateTime startTime = DateTime.Now;

            BulkTestsData testData = new BulkTestsData(CatalogueRepository, DiscoveredDatabaseICanCreateRandomTablesIn, numberOfRecordsToGenerate);

            testData.SetupTestData();
            testData.ImportAsCatalogue();

            DQERepository dqeRepository = new DQERepository(CatalogueRepository);

            //the shouldn't be any lingering results in the database
            Assert.IsNull(dqeRepository.GetMostRecentEvaluationFor(_catalogue));

            //set some validation rules
            testData.catalogue.ValidatorXML = bulkTestDataValidation;

            //set the time periodicity field
            var toBeTimePeriodicityCol = testData.catalogue.GetAllExtractionInformation(ExtractionCategory.Any).Single(e => e.GetRuntimeName().Equals("dtCreated"));

            testData.catalogue.TimeCoverage_ExtractionInformation_ID = toBeTimePeriodicityCol.ID;

            //do the validation
            CatalogueConstraintReport report = new CatalogueConstraintReport(testData.catalogue, SpecialFieldNames.DataLoadRunID);

            report.Check(new ThrowImmediatelyCheckNotifier());

            CancellationTokenSource source = new CancellationTokenSource();

            if (testCancellingValiationEarly)
            {
                source.Cancel();
            }

            ToMemoryDataLoadEventListener listener = new ToMemoryDataLoadEventListener(false);

            report.GenerateReport(testData.catalogue, listener, source.Token);

            if (testCancellingValiationEarly)
            {
                Assert.IsTrue(listener.EventsReceivedBySender[report].Count(m => m.Exception is OperationCanceledException) == 1);
                testData.Destroy();
                testData.DeleteCatalogue();
                return;
            }

            Assert.IsTrue(listener.EventsReceivedBySender[report].All(m => m.Exception == null));//all messages must have null exceptions


            //get the reuslts now
            var results = dqeRepository.GetMostRecentEvaluationFor(testData.catalogue);

            Assert.IsNotNull(results);

            //the sum of all consquences across all data load run ids should be the record count
            Assert.AreEqual(10000, results.RowStates.Sum(r => r.Missing + r.Invalid + r.Wrong + r.Correct));

            //there should be at least 5 data load run ids (should be around 12 actually - see BulkTestData but theoretically everyone could magically - all 10,000 into 5 decades - or even less but those statistics must be astronomical)
            Assert.GreaterOrEqual(results.RowStates.Count(), 5);

            //there should be lots of column results too
            Assert.GreaterOrEqual(results.ColumnStates.Count(), 5);

            //Did it log?
            LogManager logManager = new LogManager(CatalogueRepository.GetServerDefaults().GetDefaultFor(PermissableDefaults.LiveLoggingServer_ID));
            var        log        = logManager.GetArchivalDataLoadInfos("DQE").FirstOrDefault();

            Assert.IsNotNull(log);
            Assert.GreaterOrEqual(log.StartTime, startTime);
            Assert.AreEqual(0, log.Errors.Count);
            Assert.AreEqual(numberOfRecordsToGenerate, log.TableLoadInfos.Single().Inserts);

            testData.Destroy();

            testData.DeleteCatalogue();
        }
Beispiel #3
0
 public void AfterAllTests()
 {
     testData.Destroy();
 }
Beispiel #4
0
 public void BulkTestsTearDown()
 {
     _bulkTests.Destroy();
 }
 public void AfterAllTests()
 {
     _bulkTestData.Destroy();
 }