public void DeletePlot_Stratum()
        {
            var unitCode    = "u1";
            var stratumCode = "st1";
            var plotNumber  = 1;
            var plotID      = Guid.NewGuid().ToString();

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

                var stratumPlot = new Plot_Stratum()
                {
                    CuttingUnitCode = unitCode,
                    PlotNumber      = plotNumber,
                    StratumCode     = stratumCode,
                };

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

                datastore.InsertPlot_Stratum(stratumPlot);

                var echo = datastore.GetPlot_Stratum(unitCode, stratumCode, plotNumber);
                echo.Should().NotBeNull("where's my echo");

                datastore.DeletePlot_Stratum(echo.CuttingUnitCode, echo.StratumCode, echo.PlotNumber);
            }
        }
        public void UpdatePlot_Stratum()
        {
            var unitCode    = "u1";
            var stratumCode = "st1";
            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));

                var stratumPlot = new Plot_Stratum()
                {
                    CuttingUnitCode = unitCode,
                    PlotNumber      = plotNumber,
                    StratumCode     = stratumCode,
                    IsEmpty         = false,
                };

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

                datastore.InsertPlot_Stratum(stratumPlot);

                stratumPlot.IsEmpty = true;
                datastore.UpdatePlot_Stratum(stratumPlot);

                var ourStratumPlot = datastore.GetPlot_Stratum(unitCode, stratumCode, plotNumber);

                ourStratumPlot.IsEmpty.Should().Be(true);
            }
        }
        public void InsertStratumPlot()
        {
            var plotNumber  = 1;
            var stratumCode = "st1";
            var unitCode    = "u1";
            var isEmpty     = true;
            var kpi         = 101;
            var plotID      = Guid.NewGuid().ToString();
            var cruiseID    = CruiseID;

            //var remarks = "something";

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

                var stratumPlot = new Plot_Stratum()
                {
                    CuttingUnitCode = unitCode,
                    PlotNumber      = plotNumber,
                    StratumCode     = stratumCode,
                    IsEmpty         = isEmpty,
                    KPI             = kpi,
                    //Remarks = remarks
                };

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

                datastore.InsertPlot_Stratum(stratumPlot);

                datastore.IsPlotNumberAvalible(unitCode, plotNumber).Should().BeFalse("we just took that plot number");

                var plotStratumAgain = datastore.GetPlot_Stratum(unitCode, stratumCode, plotNumber);
                plotStratumAgain.Should().NotBeNull();
                plotStratumAgain.PlotNumber.Should().Be(plotNumber);
                //ourStratumPlot.Remarks.Should().Be(remarks);
                plotStratumAgain.KPI.Should().Be(kpi);
                plotStratumAgain.IsEmpty.Should().Be(isEmpty);
                plotStratumAgain.StratumCode.Should().Be(stratumCode);
            }
        }
        public void GetPlot_Stratum()
        {
            var units  = new string[] { "u1" };
            var strata = new[]
            {
                new dbModels.Stratum {
                    StratumCode = "st1", Method = "FIX"
                },
                new dbModels.Stratum {
                    StratumCode = "st2", Method = "FIX"
                },
                new dbModels.Stratum {
                    StratumCode = "st3", Method = "FIX"
                },
            };
            var unit_strata = new[]
            {
                new dbModels.CuttingUnit_Stratum {
                    CuttingUnitCode = "u1", StratumCode = "st1"
                },
                new dbModels.CuttingUnit_Stratum {
                    CuttingUnitCode = "u1", StratumCode = "st2"
                },
                new dbModels.CuttingUnit_Stratum {
                    CuttingUnitCode = "u1", StratumCode = "st3"
                },
            };

            var plotNumber = 1;
            var plotID     = Guid.NewGuid().ToString();

            using (var database = new CruiseDatastore_V3())
            {
                var saleID   = SaleID;
                var cruiseID = CruiseID;
                InitializeDatabase(database, cruiseID, saleID, units, strata, unit_strata, null, null, null, null);

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

                datastore.GetPlotsByUnitCode(units[0]).Should().BeEmpty("we havn't added any plots yet");

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

                foreach (var st in strata)
                {
                    if (st.StratumCode == "st3")
                    {
                        continue;
                    }

                    database.Execute($"INSERT INTO Plot_Stratum (CruiseID, CuttingUnitCode, PlotNumber, StratumCode) VALUES " +
                                     $"('{cruiseID}', '{units[0]}', {plotNumber}, '{st.StratumCode}');");
                }

                foreach (var st in strata)
                {
                    var plotStratum = datastore.GetPlot_Stratum(units[0], st.StratumCode, plotNumber);
                    ValidatePlot_Stratum(plotStratum, st.StratumCode != "st3");
                }

                var nonExistantPS = datastore.GetPlot_Stratum(units[0], "st3", plotNumber);
                ValidatePlot_Stratum(nonExistantPS, false);
            }
        }