Ejemplo n.º 1
0
        public void TestHICDatabaseConfiguration_ExpectTables(bool testLookup)
        {
            var conf = new HICDatabaseConfiguration(new DiscoveredServer("localhost", "mydb",
                                                                         DatabaseType.MicrosoftSQLServer, null, null), new FixedStagingDatabaseNamer("mydb"));

            var ti     = WhenIHaveA <TableInfo>();
            var lookup = WhenIHaveA <TableInfo>();

            lookup.Name     = "MyHeartyLookup";
            lookup.Database = "LookupsDb";
            lookup.SaveToDatabase();

            var job = Mock.Of <IDataLoadJob>(m =>
                                             m.RegularTablesToLoad == new List <ITableInfo>(new [] { ti }) &&
                                             m.LookupTablesToLoad == new List <ITableInfo>(new [] { lookup }));

            var result = conf.ExpectTables(job, LoadBubble.Raw, testLookup).ToArray();

            Assert.AreEqual(testLookup ? 2 : 1, result.Length);
            StringAssert.AreEqualIgnoringCase("mydb_RAW", result[0].Database.GetRuntimeName());
            StringAssert.AreEqualIgnoringCase("My_Table", result[0].GetRuntimeName());

            if (testLookup)
            {
                StringAssert.AreEqualIgnoringCase("mydb_RAW", result[1].Database.GetRuntimeName());
                StringAssert.AreEqualIgnoringCase("MyHeartyLookup", result[1].GetRuntimeName());
            }

            result = conf.ExpectTables(job, LoadBubble.Staging, testLookup).ToArray();
            Assert.AreEqual(testLookup ? 2 : 1, result.Length);
            StringAssert.AreEqualIgnoringCase("DLE_STAGING", result[0].Database.GetRuntimeName());
            StringAssert.AreEqualIgnoringCase("mydb_My_Table_STAGING", result[0].GetRuntimeName());

            if (testLookup)
            {
                StringAssert.AreEqualIgnoringCase("DLE_STAGING", result[1].Database.GetRuntimeName());
                StringAssert.AreEqualIgnoringCase("mydb_MyHeartyLookup_STAGING", result[1].GetRuntimeName());
            }
        }
Ejemplo n.º 2
0
        // Check that either Raw database exists and is populated, or that 'forLoading' is not empty
        private void VerifyExistenceOfRawData(IDataLoadJob job)
        {
            var raw = _databaseConfiguration.DeployInfo[LoadBubble.Raw];

            if (!raw.Exists())
            {
                job.OnNotify(this, new NotifyEventArgs(ProgressEventType.Error, "The Mounting stage has not created the " + raw.GetRuntimeName() + " database."));
            }

            var rawDbInfo = _databaseConfiguration.DeployInfo[LoadBubble.Raw];

            if (_databaseConfiguration.ExpectTables(job, LoadBubble.Raw, true).All(t => t.IsEmpty()))
            {
                var message = "The Mounting stage has not populated the RAW database (" + rawDbInfo + ") with any data";
                job.OnNotify(this, new NotifyEventArgs(ProgressEventType.Error, message));
                throw new Exception(message);
            }
        }