public void TestQueriesAndInsert()
        {
            using (var context = TestDwhDbContext.CreateDWHDbContext()) {
                var hubRepo       = new HubRepository <H_TestHub_Stores>(context, HashFunctions.MD5, null);
                var satelliteRepo = new SatelliteRepository <S_TestSatellite_Stores>(context, HashFunctions.MD5);
                var linkRepo      = new LinkRepository <L_TestLink_Stores>(context, HashFunctions.MD5, null, DVKeyCaching.Disabled);

                var loadDate = DateTime.Now;

                // HUB - storing info
                hubRepo.Insert(TestHub1, loadDate, loadInformation: LoadInfo1);

                var hub = hubRepo.GetByKey(TestHub1.PrimaryKey);

                Assert.Equal(LoadInfo1.RecordSource, hub.RecordSource);
                Assert.Equal(LoadInfo1.LoadedBy, hub.LoadedBy);

                // SATELLITE - storing info
                Hub1Satellite1 = satelliteRepo.Insert(Hub1Satellite1, loadDate, loadInformation: LoadInfo1);

                var sat = satelliteRepo.GetCurrent(s => s.Reference == TestHub1.PrimaryKey).Single();

                Assert.Equal(LoadInfo1.RecordSource, sat.RecordSource);
                Assert.Equal(LoadInfo1.LoadedBy, sat.LoadedBy);

                // LINK - storing info
                Link1 = linkRepo.Insert(Link1, loadDate, loadInformation: LoadInfo1);

                var link = linkRepo.GetByKey(Link1.PrimaryKey);

                Assert.Equal(LoadInfo1.RecordSource, link.RecordSource);
                Assert.Equal(LoadInfo1.LoadedBy, link.LoadedBy);
            }
        }
        public SatelliteDetails GetSatelliteDetailsBySatelliteName(string Satellite = null)
        {
            SatelliteRepository sRepo            = new SatelliteRepository();
            SatelliteDetails    satelliteDetails = new SatelliteDetails();

            satelliteDetails = sRepo.GetSatelliteDetailsBySatelliteName(Satellite);
            return(satelliteDetails);
        }
        public List <SatelliteDetails> GetAllSatelliteDetailsByCountry(string Country)
        {
            SatelliteRepository     sRepo            = new SatelliteRepository();
            List <SatelliteDetails> satelliteDetails = new List <SatelliteDetails>();

            satelliteDetails = sRepo.GetSatelliteDetails(Country);
            return(satelliteDetails);
        }
        public List <SatelliteDetails> GetAllSatelliteDetails()
        {
            SatelliteRepository     sRepo            = new SatelliteRepository();
            List <SatelliteDetails> satelliteDetails = new List <SatelliteDetails>();

            satelliteDetails = sRepo.GetSatelliteDetails();
            return(satelliteDetails);
        }
        public SatelliteDetails GetSatelliteDetailsByName(string satelliteName = null)
        {
            SatelliteRepository srepo  = new SatelliteRepository();
            SatelliteDetails    result = new SatelliteDetails();

            result = srepo.GetSatelliteDetailsBySatelliteName(satelliteName);
            return(result);
        }
        public List <SatelliteDetails> GetSatelliteDetailsByCountry(string country = null)
        {
            SatelliteRepository     srepo  = new SatelliteRepository();
            List <SatelliteDetails> result = new List <SatelliteDetails>();

            result = srepo.GetSatelliteDetails(country);
            return(result);
        }
        private int GetAllSatellites(string country = null)
        {
            SatelliteRepository     repo   = new SatelliteRepository();
            List <SatelliteDetails> result = new List <SatelliteDetails>();

            result = repo.GetSatelliteDetails(country);
            return(result.Count);
        }
Esempio n. 8
0
        public void EmptySetsYieldNoResults()
        {
            using (var context = TestDwhDbContext.CreateDWHDbContext()) {
                var testRepo = new SatelliteRepository <S_TestSatellite_Default>(context, HashFunctions.MD5);

                var testList = testRepo.Get();
                Assert.Empty(testList);

                testList = testRepo.GetAll();
                Assert.Empty(testList);
            }
        }
        public void TestQueriesAndInsert()
        {
            using (var context = TestDwhDbContext.CreateDWHDbContext()) {
                var referenceRepo = new CRUDRepository <LoadInformation, long>(context);

                var hubRepo       = new HubRepository <H_TestHub_References>(context, HashFunctions.MD5, null);
                var satelliteRepo = new SatelliteRepository <S_TestSatellite_References>(context, HashFunctions.MD5);
                var linkRepo      = new LinkRepository <L_TestLink_References>(context, HashFunctions.MD5, null, DVKeyCaching.Disabled);

                var loadDate = DateTime.Now;

                // REFERENCE ENTRY - inserting and data persistence tests
                var load1Key = referenceRepo.Insert(LoadInfo1);
                var load2Key = referenceRepo.Insert(LoadInfo2);

                var hubList = referenceRepo.Get();
                Assert.NotEmpty(hubList);
                Assert.Equal(2, hubList.Count());
                Assert.False(load1Key == default);
                Assert.False(load2Key == default);

                var loadInfo = referenceRepo.Get(x => x.PrimaryKey == load2Key).Single();

                Assert.Equal(LoadInfo2.RecordSource, loadInfo.RecordSource);
                Assert.Equal(LoadInfo2.LoadedBy, loadInfo.LoadedBy);

                // HUB - referencing
                TestHub1 = hubRepo.Insert(TestHub1, loadDate, loadReference: LoadInfo1);
                TestHub2 = hubRepo.Insert(TestHub2, loadDate, loadReference: LoadInfo2);
                Assert.Equal(load1Key, TestHub1.LoadReference);
                Assert.Equal(load2Key, TestHub2.LoadReference);

                // SATELLITE - referencing
                Hub1Satellite1 = satelliteRepo.Insert(Hub1Satellite1, loadDate, loadReference: LoadInfo1);
                Hub2Satellite1 = satelliteRepo.Insert(Hub2Satellite1, loadDate, loadReference: LoadInfo2);

                Assert.Equal(load1Key, Hub1Satellite1.LoadReference);
                Assert.Equal(load2Key, Hub2Satellite1.LoadReference);

                var satelliteList = satelliteRepo.GetCurrent();
                Assert.NotEmpty(satelliteList);
                Assert.Equal(2, satelliteList.Count());


                // LINK - referencing
                Link1 = linkRepo.Insert(Link1, loadDate, loadReference: LoadInfo1);

                Assert.Equal(load1Key, Link1.LoadReference);

                Link1 = linkRepo.Get().Single();
                Assert.Equal(load1Key, Link1.LoadReference);
            }
        }
Esempio n. 10
0
        public void DuplicatePrimaryKeyException()
        {
            using (var context = TestDwhDbContext.CreateDWHDbContext()) {
                var satelliteRepo = new SatelliteRepository <S_TestSatellite_Default>(context, HashFunctions.MD5);

                var loadDate = DateTime.Now;

                //single insert
                satelliteRepo.Insert(Hub1Satellite1, loadDate);

                // same key (same loaddate) again
                Assert.Throws <InvalidOperationException>(() => satelliteRepo.Insert(Hub1Satellite2, loadDate));
            }
        }
Esempio n. 11
0
        public void TestQueriesAndInsert()
        {
            using (var context = TestDwhDbContext.CreateDWHDbContext()) {
                var hubRepo       = new HubRepository <H_TestHub_Default>(context, HashFunctions.MD5, null);
                var satelliteRepo = new SatelliteRepository <S_TestSatellite_Default>(context, HashFunctions.MD5);

                var loadDate = DateTime.Now;

                hubRepo.Insert(TestHub1, loadDate);
                hubRepo.Insert(TestHub2, loadDate);

                var hubList = hubRepo.Get();
                Assert.NotEmpty(hubList);
                Assert.Equal(2, hubList.Count());


                satelliteRepo.Insert(Hub1Satellite1, loadDate);
                satelliteRepo.Insert(Hub2Satellite1, loadDate);

                var satelliteList = satelliteRepo.GetCurrent();
                Assert.NotEmpty(satelliteList);
                Assert.Equal(2, satelliteList.Count());

                //increment load date to simulate later insert of new data slice
                loadDate = loadDate.AddDays(1);

                satelliteRepo.Insert(Hub1Satellite2, loadDate);
                satelliteRepo.Insert(Hub2Satellite2, loadDate);

                satelliteList = satelliteRepo.GetCurrent();
                Assert.NotEmpty(satelliteList);
                Assert.Equal(2, satelliteList.Count());

                var satHub1 = satelliteList.Where(sat => sat.TestNr == TestHubBusinessKey1).Single();
                var satHub2 = satelliteList.Where(sat => sat.TestNr == TestHubBusinessKey2).Single();

                Assert.Equal(Hub1Satellite2, satHub1);
                Assert.Equal(Hub2Satellite2, satHub2);


                // a total of 4 should now be stored in the db
                satelliteList = satelliteRepo.GetAll();
                Assert.NotEmpty(satelliteList);
                Assert.Equal(4, satelliteList.Count());
            }
        }
Esempio n. 12
0
        public void KeyCalculation()
        {
            using (var context = TestDwhDbContext.CreateDWHDbContext()) {
                var hubRepo       = new HubRepository <H_TestHub_Default>(context, HashFunctions.MD5, null, DVKeyCaching.Disabled);
                var satelliteRepo = new SatelliteRepository <S_TestSatellite_Default>(context, HashFunctions.MD5);

                var loadDate = DateTime.Now;

                //single insert
                var testHub = hubRepo.Insert(TestHub1, loadDate);
                Assert.Equal(HashFunctions.MD5(testHub.GetBusinessKeyString()), testHub.PrimaryKey);
                Assert.Equal(HashFunctions.MD5(testHub.GetBusinessKeyString()), hubRepo.CalculateHashes(testHub).PrimaryKey);

                //single insert
                var testSatellite = satelliteRepo.Insert(Hub1Satellite1, loadDate);
                Assert.Equal(HashFunctions.MD5(testHub.GetBusinessKeyString()), testSatellite.Reference);
                Assert.Equal(HashFunctions.MD5(testHub.GetBusinessKeyString()), testSatellite.PrimaryKey.Reference);
            }
        }