Esempio n. 1
0
        public void SyncStratumTemplates_Add()
        {
            var fromPath = base.GetTempFilePath(".crz3", "SyncStratumTemplates_Add_fromFile");
            var toPath   = base.GetTempFilePath(".crz3", "SyncStratumTemplates_Add_toFile");

            var syncOptions = new CruiseSyncOptions()
            {
                Processing = SyncFlags.Insert,
            };

            var init     = new DatabaseInitializer();
            var cruiseID = init.CruiseID;
            var saleID   = init.SaleID;

            using var fromDb = init.CreateDatabaseFile(fromPath);

            fromDb.CopyTo(toPath, true);
            using var toDb = new CruiseDatastore_V3(toPath);

            var st = new StratumTemplate
            {
                CruiseID            = cruiseID,
                StratumTemplateName = "something",
            };

            fromDb.Insert(st);

            var syncer = new CruiseSyncer();

            syncer.Sync(cruiseID, fromDb, toDb, syncOptions);

            toDb.From <StratumTemplate>().Count().Should().Be(1);
        }
Esempio n. 2
0
        public void Sync_SampleGroup_Delete()
        {
            var init     = new DatabaseInitializer();
            var fromPath = base.GetTempFilePath(".crz3", "Sync_SampleGroup_Delete_fromFile");
            var toPath   = base.GetTempFilePath(".crz3", "Sync_SampleGroup_Delete_toFile");

            using var fromDb = init.CreateDatabaseFile(fromPath);
            var cruiseID = init.CruiseID;
            var saleID   = init.SaleID;

            var newStratum = new Stratum
            {
                CruiseID    = cruiseID,
                StratumID   = Guid.NewGuid().ToString(),
                StratumCode = "newStratumCode1",
            };

            fromDb.Insert(newStratum);

            fromDb.CopyTo(toPath, true);
            using var toDb = new CruiseDatastore_V3(toPath);

            fromDb.Delete(newStratum);

            var syncer      = new DeleteSysncer();
            var syncOptions = new CruiseSyncOptions();

            syncer.Sync(cruiseID, fromDb, toDb, syncOptions);

            toDb.GetRowCount("Stratum", "WHERE StratumID = @p1", newStratum.StratumID)
            .Should().Be(0);
        }
Esempio n. 3
0
        public void Sync_Cruise_Add()
        {
            var fromPath = base.GetTempFilePath(".crz3", "Cruise_Add_fromFile");
            var toPath   = base.GetTempFilePath(".crz3", "Cruise_Add_toFile");

            var syncOptions = new CruiseSyncOptions();

            var init       = new DatabaseInitializer();
            var cruiseID   = init.CruiseID;
            var saleID     = init.SaleID;
            var saleNumber = init.SaleNumber;

            using var fromDb = init.CreateDatabaseFile(fromPath);

            fromDb.CopyTo(toPath, true);
            using var toDb = new CruiseDatastore_V3(toPath);

            var newCruise = new Cruise
            {
                CruiseID     = Guid.NewGuid().ToString(),
                CruiseNumber = "123456789",
                SaleID       = saleID,
                SaleNumber   = saleNumber,
            };

            fromDb.Insert(newCruise);
            newCruise = fromDb.From <Cruise>().Where("CruiseID = @p1")
                        .Query(newCruise.CruiseID).FirstOrDefault();

            var syncer = new CruiseSyncer();

            syncer.Sync(newCruise.CruiseID, fromDb, toDb, syncOptions);

            var newCruiseAgain = toDb.From <Cruise>()
                                 .Where("CruiseID = @p1")
                                 .Query(newCruise.CruiseID).FirstOrDefault();

            newCruiseAgain.Should().NotBeNull();
            newCruiseAgain.Should().BeEquivalentTo(newCruise, x => x
                                                   .Excluding(y => y.Modified_TS));
        }
Esempio n. 4
0
        public void SyncTreeDefaultValues_Add()
        {
            var fromPath = base.GetTempFilePath(".crz3", "SyncTreeDefaultValues_Add_fromFile");
            var toPath   = base.GetTempFilePath(".crz3", "SyncTreeDefaultValues_Add_toFile");

            var syncOptions = new CruiseSyncOptions()
            {
                Processing = SyncFlags.Insert,
            };

            var init = new DatabaseInitializer()
            {
                TreeDefaults = null,
            };
            var cruiseID = init.CruiseID;
            var saleID   = init.SaleID;

            using var fromDb = init.CreateDatabaseFile(fromPath);

            fromDb.CopyTo(toPath, true);
            using var toDb = new CruiseDatastore_V3(toPath);

            var tdv = new TreeDefaultValue
            {
                CruiseID       = cruiseID,
                SpeciesCode    = "sp1",
                PrimaryProduct = "01",
            };

            fromDb.Insert(tdv);

            var syncer = new CruiseSyncer();

            syncer.Sync(cruiseID, fromDb, toDb, syncOptions);

            toDb.From <TreeDefaultValue>().Count().Should().Be(1);
        }
Esempio n. 5
0
        public void GetSaleConflicts_dupSale()
        {
            var srcFile  = GetTempFilePath(".crz3", "GetSaleConflicts_srcFile");
            var destFile = GetTempFilePath(".crz3", "GetSaleConflicts_destFile");

            var saleNumber      = "12345";
            var srcInitialaizer = new DatabaseInitializer()
            {
                SaleNumber = saleNumber
            };
            var destInitializer = new DatabaseInitializer()
            {
                SaleNumber = saleNumber
            };

            using (var srcDb = srcInitialaizer.CreateDatabaseFile(srcFile))
                using (var desDb = destInitializer.CreateDatabaseFile(destFile))
                {
                    var cc = new CruiseChecker();

                    var result = cc.GetSaleConflicts(srcDb, desDb, srcInitialaizer.CruiseID);
                    result.Should().NotBeEmpty();
                }
        }