public void GetPlot_Strata()
        {
            var unitCode   = "u1";
            var strata     = new string[] { "st1", "st2" };
            var plotNumber = 1;
            var plotID     = Guid.NewGuid().ToString();
            var cruiseID   = CruiseID;

            using (var database = CreateDatabase())
            {
                var datastore = new CuttingUnitDatastore(database, cruiseID, TestDeviceInfoService.TEST_DEVICEID, new SamplerInfoDataservice(database, CruiseID, TestDeviceInfoService.TEST_DEVICEID));

                datastore.GetPlotsByUnitCode(unitCode).Should().BeEmpty("we havn't added any plots yet");

                database.Execute($"INSERT INTO Plot (CruiseID, PlotID, CuttingUnitCode, PlotNumber) VALUES " +
                                 $"('{cruiseID}', '{plotID}', '{unitCode}', {plotNumber})");

                foreach (var st in strata)
                {
                    database.Execute($"INSERT INTO Plot_Stratum (CruiseID, CuttingUnitCode, PlotNumber, StratumCode) VALUES " +
                                     $"('{cruiseID}', '{unitCode}', {plotNumber}, '{st}');");
                }

                var stPlots = datastore.GetPlot_Strata(unitCode, plotNumber);

                stPlots.Should().HaveCount(strata.Count());

                foreach (var ps in stPlots)
                {
                    ValidatePlot_Stratum(ps, true);
                }
            }
        }
        public void GetPlotTreeProxies()
        {
            var unitCode   = "u1";
            var plotNumber = 1;

            using (var db = CreateDatabase())
            {
                var ds     = new CuttingUnitDatastore(db, CruiseID, TestDeviceInfoService.TEST_DEVICEID, new SamplerInfoDataservice(db, CruiseID, TestDeviceInfoService.TEST_DEVICEID));
                var plotid = ds.AddNewPlot(unitCode);

                var plot_stratum = ds.GetPlot_Strata(unitCode, plotNumber).First();

                var tp = ds.GetPlotTallyPopulationsByUnitCode(unitCode, plotNumber).First();

                var firstTreeid = ds.CreatePlotTree(unitCode, plotNumber, tp.StratumCode, tp.SampleGroupCode);
                ds.CreatePlotTree(unitCode, plotNumber, tp.StratumCode, tp.SampleGroupCode);

                var trees = ds.GetPlotTreeProxies(unitCode, plotNumber).ToArray();

                trees.Should().HaveCount(2);
                trees.Select(x => x.TreeNumber).Should().BeInAscendingOrder();

                db.Execute("UPDATE Tree SET TreeNumber = 3 WHERE TreeNumber = 1;");

                var treesAgain = ds.GetPlotTreeProxies(unitCode, plotNumber).ToArray();
                treesAgain.Select(x => x.TreeNumber).Should().BeInAscendingOrder();
            }
        }
        private static void validatePlot(CuttingUnitDatastore datastore, string unitCode, string plotID, int expectedPlotNumber)
        {
            plotID.Should().NotBeNullOrEmpty();

            var plot = datastore.GetPlot(plotID);

            plot.Should().NotBeNull();
            plot.PlotNumber.Should().Be(expectedPlotNumber);

            var strat_plots = datastore.GetPlot_Strata(unitCode, plot.PlotNumber);

            strat_plots.Should().NotBeEmpty();

            strat_plots.All(x => x.PlotNumber == expectedPlotNumber).Should().BeTrue();
        }
Пример #4
0
        public void GetPlot_Strata()
        {
            var init = new DatastoreInitializer();
            var unit = init.Units[0];

            using (var db = init.CreateDatabase())
            {
                var ds = new CuttingUnitDatastore(db, init.CruiseID, TestDeviceInfoService.TEST_DEVICEID, new SamplerInfoDataservice(db, init.CruiseID, init.DeviceID));

                ds.AddNewPlot(unit);

                var plots = ds.GetPlotsByUnitCode(unit);
                plots.Should().HaveCount(1);
                var plot = plots.Single();

                var plotStrata = ds.GetPlot_Strata(unit, plot.PlotNumber, insertIfNotExists: false);
                plotStrata.Should().HaveCount(2);
            }
        }