コード例 #1
0
        public void DecrementFixCNTTreeCount()
        {
            var unitCode   = Units.First();
            var plotNumber = 1;
            var fieldName  = "DBH";
            var value      = 10;

            var subpop = Subpops.First();

            var sgCode = subpop.SampleGroupCode;
            var stCode = subpop.StratumCode;
            var sp     = subpop.SpeciesCode;
            var ld     = subpop.LiveDead;

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

                var plotID = plotds.AddNewPlot(unitCode);

                var ds = new FixCNTDataservice(database, CruiseID, TestDeviceInfoService.TEST_DEVICEID);

                // check initial state
                ds.GetTreeCount(unitCode, plotNumber, stCode, sgCode, sp, ld, fieldName, value)
                .Should().Be(0);

                // increment once
                ds.IncrementFixCNTTreeCount(unitCode, plotNumber, stCode, sgCode, sp, ld, fieldName, value);
                ds.GetTreeCount(unitCode, plotNumber, stCode, sgCode, sp, ld, fieldName, value)
                .Should().Be(1);

                // decrement back to zero
                ds.DecrementFixCNTTreeCount(unitCode, plotNumber, stCode, sgCode, sp, ld, fieldName, value);
                ds.GetTreeCount(unitCode, plotNumber, stCode, sgCode, sp, ld, fieldName, value)
                .Should().Be(0);

                // try to decrement past zero should only result in count of zero
                ds.DecrementFixCNTTreeCount(unitCode, plotNumber, stCode, sgCode, sp, ld, fieldName, value);
                ds.GetTreeCount(unitCode, plotNumber, stCode, sgCode, sp, ld, fieldName, value)
                .Should().Be(0);
            }
        }
コード例 #2
0
        //public void Tally(string species, Double midValue)
        //{
        //    var tallyPopulation = TallyPopulations.Where(x => x.Species == species).First();

        //    var bucket = tallyPopulation.Buckets.Where(x => x.Value == midValue).Single();

        //    Tally(bucket);
        //}

        public void UnTally(FixCNTTallyBucket tallyBucket)
        {
            var tallyPop = tallyBucket.TallyPopulation;

            FixCNTDataservice.DecrementFixCNTTreeCount(
                Unit,
                PlotNumber,
                tallyPop.StratumCode,
                tallyPop.SampleGroupCode,
                tallyPop.SpeciesCode,
                tallyPop.LiveDead,
                tallyPop.FieldName,
                tallyBucket.Value);

            tallyBucket.TreeCount = Math.Max(0, tallyBucket.TreeCount - 1);
        }