public void GetTallyEntriesByUnitCode()
        {
            var unit        = Units.First();
            var subpop      = Subpops[0];
            var stratum     = subpop.StratumCode;
            var sampleGroup = subpop.SampleGroupCode;
            var species     = subpop.SpeciesCode;
            var liveDead    = subpop.LiveDead;

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

                var pop = tpds.GetTallyPopulation(unit, stratum, sampleGroup, species, liveDead);

                // insert entry using InsertTallyAction
                datastore.InsertTallyAction(new TallyAction(unit, pop));
                var tallyEntries = datastore.GetTallyEntriesByUnitCode(unit);
                tallyEntries.Should().HaveCount(1);

                // add another entry using insertTallyLedger
                datastore.InsertTallyLedger(new TallyLedger(unit, pop));
                tallyEntries = datastore.GetTallyEntriesByUnitCode(unit);
                tallyEntries.Should().HaveCount(2);

                // inset a tally ledger with plot number
                // and conferm that GetTallyEntriesByUnitCode doesn't return plot tally entries
                cuds.AddNewPlot(unit);
                datastore.InsertTallyAction(new TallyAction(unit, 1, pop));
                tallyEntries = datastore.GetTallyEntriesByUnitCode(unit);
                tallyEntries.Should().HaveCount(2);
            }
        }
        public void InsertTallyLedger()
        {
            string unitCode    = UnitStrata[0].CuttingUnitCode;
            string stratum     = UnitStrata[0].StratumCode;
            string sampleGroup = Subpops[0].SampleGroupCode;
            string species     = Subpops[0].SpeciesCode;
            string liveDead    = Subpops[0].LiveDead;

            int treeCountDiff = 1;
            int kpi           = 1;

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

                var pop = tpds.GetTallyPopulation(unitCode, stratum, sampleGroup, species, liveDead);
                pop.Should().NotBeNull();
                VerifyTallyPopulation(pop);
                pop.TreeCount.Should().Be(0);
                pop.SumKPI.Should().Be(0);

                var tallyLedger = new TallyLedger(unitCode, pop);
                tallyLedger.TreeCount = treeCountDiff;
                tallyLedger.KPI       = 1;

                datastore.InsertTallyLedger(tallyLedger);

                database.ExecuteScalar <int>("SELECT count(*) FROM TallyLedger;").Should().Be(1);
                database.ExecuteScalar <int>("SELECT sum(TreeCount) FROM TallyLedger;").Should().Be(treeCountDiff);

                var popAfter = tpds.GetTallyPopulation(unitCode, stratum, sampleGroup, species, liveDead);
                popAfter.TreeCount.Should().Be(treeCountDiff);
                popAfter.SumKPI.Should().Be(kpi);
            }
        }