コード例 #1
0
        public void Cleanup()
        {
            container1.DeleteInDatabase();

            if (aggregate1 != null)
            {
                aggregate1.DeleteInDatabase();
            }

            if (aggregate2 != null)
            {
                aggregate2.DeleteInDatabase();
            }

            if (aggregate3 != null)
            {
                aggregate3.DeleteInDatabase();
            }


            if (cohortIdentificationConfiguration != null)
            {
                cohortIdentificationConfiguration.DeleteInDatabase();
            }

            if (testData != null)
            {
                testData.DeleteCatalogue();
            }
        }
コード例 #2
0
        public void DeleteAReferencedValidationXML()
        {
            ColumnInfo    l2ColumnInfo;
            BulkTestsData testData = SetupTestData(out l2ColumnInfo);

            try
            {
                Validator.LocatorForXMLDeserialization = RepositoryLocator;

                var worked = Validator.LoadFromXml(testData.catalogue.ValidatorXML);

                //notice that it is the ID of the referenced column that is maintained not the name of it! that is because we need to use a data access portal to get the contents of the column which might be in a different table (and normally would be)
                Assert.IsFalse(testData.catalogue.ValidatorXML.Contains("previous_address_L2"));
                Assert.IsTrue(testData.catalogue.ValidatorXML.Contains(l2ColumnInfo.ID.ToString()));

                Assert.IsTrue(testData.catalogue.ValidatorXML.Contains("previous_address_L1"));

                //we expect the validation XML to find the reference
                ValidationXMLObscureDependencyFinder finder = new ValidationXMLObscureDependencyFinder(RepositoryLocator);

                //and explode
                Assert.Throws <ValidationXmlDependencyException>(() => finder.ThrowIfDeleteDisallowed(l2ColumnInfo));

                Assert.AreEqual(0, finder.BlackList.Count);

                //now clear the validation XML
                testData.catalogue.ValidatorXML = testData.catalogue.ValidatorXML.Insert(100, "I've got a lovely bunch of coconuts!");
                testData.catalogue.SaveToDatabase();

                //column info should be deleteable but only because we got ourselves onto the blacklist
                Assert.DoesNotThrow(() => finder.ThrowIfDeleteDisallowed(l2ColumnInfo));
                Assert.AreEqual(1, finder.BlackList.Count);

                testData.catalogue.ValidatorXML = "";
                testData.catalogue.SaveToDatabase();

                //column info should be deleteable now that we cleared the XML
                Assert.DoesNotThrow(() => finder.ThrowIfDeleteDisallowed(l2ColumnInfo));
            }
            finally
            {
                testData.DeleteCatalogue();
            }
        }
コード例 #3
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();
        }