protected void OnTallyButtonClicked(object sender, EventArgs e)
        {
            var       row   = (ITallyButton)sender;
            CountTree count = row.Count;

            OnTally(count);
        }
        //protected void OnSpeciesButtonClick(object sender, EventArgs e)
        //{
        //    if (_viewLoading) { return; }
        //    Button button = (Button)sender;
        //    SubPop subPop = (SubPop)button.Tag;

        //    var tree = DataService.CreateNewTreeEntry(subPop.SG.Stratum, subPop.SG, subPop.TDV, true);
        //    tree.TreeCount = 1;

        //    DialogService.AskCruiser(tree);

        //    DataService.AddNonPlotTree(tree);
        //    DataEntryForm.GotoTreePage();
        //}

        protected void OnTallySettingsClicked(object sender, EventArgs e)
        {
            var       row   = (ITallyButton)sender;
            CountTree count = row.Count;

            try
            {
                count.Save();
                var countTreeDataService = new CountTreeDataService(DataService.DataStore, count);
                using (FormTallySettings view = new FormTallySettings(countTreeDataService, SampleSelectorRepository))
                {
#if !NetCF
                    view.Owner = this.TopLevelControl as Form;
#endif
                    view.ShowDialog();
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex);
                return;
            }

            //row.DiscriptionLabel.Text = count.Tally.Description;
        }
Example #3
0
        public void TestTreeTally(System.IO.TextWriter output)
        {
            var st = _dataStore.From <Stratum>().Read().First();

            var sg = _dataStore.From <SampleGroup>().Read().First();

            sg.SampleSelectorType = CruiseDAL.Enums.SampleSelectorType.Block.ToString();

            CountTree count = _dataStore.From <CountTree>().Read().First();

            var stopwatch = new OpenNETCF.Diagnostics.Stopwatch();

            stopwatch.Start();
            int numSamples = 500;

            for (int i = 0; i < numSamples; i++)
            {
                _de.OnTally(count);
            }
            stopwatch.Stop();

            output.WriteLine("Sample Count = " + _controller.SampleCount.ToString());
            output.WriteLine("ISample Count = " + _controller.ISampleCount.ToString());
            output.WriteLine("Runtime (millSec): " + stopwatch.ElapsedMilliseconds.ToString());
        }
Example #4
0
        public void TallyThreePTest_UserDontEnterKPI()
        {
            int?expectedKPI = null;
            int minKPI      = 101;
            int maxKPI      = 102;

            var dialogServiceMock = new Mock <IDialogService>();

            dialogServiceMock.Setup(ds => ds.AskKPI(It.Is <int>(x => x == minKPI), It.Is <int>(x => x == maxKPI), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()))
            .Returns(expectedKPI);

            var sg = new SampleGroup()
            {
                MinKPI = minKPI, MaxKPI = maxKPI
            };

            var count = new CountTree()
            {
                TreeCount = 0, SumKPI = 0
            };
            var sampleSelector = new FMSC.Sampling.ThreePSelecter(1, 0);

            var expectedTree    = new Tree();
            var dataServiceMock = new Moq.Mock <ITreeDataService>();

            dataServiceMock.Setup(ds => ds.CreateNewTreeEntry(It.IsAny <CountTree>())).Returns(expectedTree);

            var result = FormDataEntryLogic.TallyThreeP(count, sampleSelector, sg, dataServiceMock.Object, dialogServiceMock.Object);

            result.Should().BeNull();
        }
        public void OnTally(CountTree count)
        {
            if (!this.EnsureCurrentPlotWorkable())
            {
                return;
            }

            OnTally(count, this.CurrentPlot);
        }
Example #6
0
        public TallyRow(CountTree count)
        {
            InitializeComponent();

            _tallyBTN.Click    += new EventHandler(this.OnTallyButtonClicked);
            _settingsBTN.Click += new EventHandler(this.OnSettingsButtonClicked);
            this.Count          = count;
            UpdateTallyButton();
        }
Example #7
0
 public CountTree(int lowerBound, int upperBound)
 {
     LowerBound = lowerBound;
     UpperBound = upperBound;
     if (LowerBound < UpperBound)
     {
         LeftTree = new CountTree(LowerBound, (LowerBound + UpperBound) / 2);
         RightTree = new CountTree((LowerBound + UpperBound) / 2 + 1, UpperBound);
     }
 }
Example #8
0
        public bool HandleKeyPress(string keyStr)
        {
            var view = this.View.FocusedLayout;

            if (view != null)
            {
                if (view.PreviewKeypress(keyStr))
                {
                    return(true);
                }
                else if (keyStr.Length == 1)
                {
                    var key = keyStr.FirstOrDefault();
                    if (key == char.MinValue)
                    {
                        return(false);
                    }
                    key = char.ToUpper(key);
                    if (!IsHotkeyKey(key))
                    {
                        return(false);
                    }

                    var tallyView = view as ITallyView;
                    if (tallyView != null)
                    {
                        if (tallyView.HotKeyEnabled == false)
                        {
                            return(false);
                        }

                        if (tallyView.HotKeyLookup != null && tallyView.HotKeyLookup.ContainsKey(key))//maybe a tally hotkey
                        {
                            CountTree count = tallyView.HotKeyLookup[key];
                            tallyView.OnTally(count);
                            return(true);
                        }

                        //if valid stratm hot key, go to view that stratum belongs to
                        if (this.StratumHotKeyLookup.ContainsKey(key))
                        {
                            this.View.GoToPage(this.StratumHotKeyLookup[key]);
                            return(true);
                        }
                        else//not valid hotkey, get grumpy
                        {
                            _soundService.SignalInvalidAction();
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
Example #9
0
        public CountTreeDataService(DAL datastore, CountTree count)
        {
            if (datastore == null)
            {
                throw new ArgumentNullException("datastore");
            }
            if (count == null)
            {
                throw new ArgumentNullException("count");
            }

            Datastore = datastore;
            Count     = count;
        }
        Control MakeTallyRow(Control container, CountTree count)
        {
            var row = new TallyRow(count);

            row.SuspendLayout();

            row.TallyButtonClicked    += new EventHandler(this.OnTallyButtonClicked);
            row.SettingsButtonClicked += new EventHandler(this.OnTallySettingsClicked);

            row.Parent = container;
            row.AdjustHeight();

            row.Dock = DockStyle.Top;
            row.ResumeLayout(false);
            return(row);
        }
        public Control MakeTallyRow(Control container, CountTree count)
        {
            var row = new PlotTallyRow(count);

            row.SuspendLayout();

            row.TallyButtonClicked    += new EventHandler(this.tallyRow_TallyButtonClicked);
            row.SettingsButtonClicked += new EventHandler(this.tallyRow_InfoButtonClicked);

            row.Height = 56;
            row.Parent = container;

            row.Dock = DockStyle.Top;
            row.ResumeLayout(true);
            return(row);
        }
Example #12
0
        Control MakeTallyRow(Control container, CountTree count)
        {
            var row = new PlotTallyButton(count);

            row.SuspendLayout();

            row.TallyButtonClicked    += new EventHandler(this.tallyRow_TallyButtonClicked);
            row.SettingsButtonClicked += new EventHandler(this.tallyRow_InfoButtonClicked);

            //row.Width = 90;
            row.Parent = container;

            row.Dock = DockStyle.Left;
            row.ResumeLayout(false);
            return(row);
        }
Example #13
0
        public TreeEstimateDO LogTreeEstimate(CountTree count, int kpi)
        {
            if (count == null)
            {
                throw new ArgumentNullException("count");
            }

            var te = new TreeEstimateDO(DataStore)
            {
                KPI       = kpi,
                CountTree = count
            };

            te.Save();

            return(te);
        }
Example #14
0
        public void PopulateHotKeyLookupTest()
        {
            var stratum = new Stratum();

            var counts = new CountTree[]
            { new CountTree()
              {
                  Tally = new TallyDO()
                  {
                      Hotkey = "A"
                  }
              },
              new CountTree()
              {
                  Tally = new TallyDO()
                  {
                      Hotkey = "Banana"
                  }
              },
              new CountTree()
              {
                  Tally = new TallyDO()
                  {
                      Hotkey = "cat"
                  }
              } };

            var samplegroups = new SampleGroup[] {
                new SampleGroup()
                {
                    Counts = counts
                }
            };

            stratum.SampleGroups = new List <SampleGroup>(samplegroups);

            stratum.HotKeyLookup.Should().NotBeNull();

            stratum.PopulateHotKeyLookup();
            stratum.HotKeyLookup.Should().NotBeNull();
            stratum.HotKeyLookup.ContainsKey('A').Should().BeTrue();
            stratum.HotKeyLookup.ContainsKey('B').Should().BeTrue();
            stratum.HotKeyLookup.ContainsKey('C').Should().BeTrue();
            stratum.HotKeyLookup.ContainsKey('D').Should().BeFalse();
        }
Example #15
0
        //ViewController (askKPI) //TODO use Dialog Service instead
        //DataService (CreateNewTreeEntry)
        //DAL (LogTreeEstimate) //should be dataservice instead
        //SampleGroup (MinKPI/MaxKPI)
        public static TallyAction TallyThreeP(CountTree count, ISampleSelector sampler, SampleGroup sg, ITreeDataService dataService, IDialogService dialogService)
        {
            TallyAction action = new TallyAction(count)
            {
                TreeCount = 1,
            };

            var sgCode = sg.Code;
            var stCode = sg.Stratum.Code;
            var spCode = count.TreeDefaultValue.Species;
            int kpi    = 0;
            int?value  = dialogService.AskKPI((int)sg.MinKPI, (int)sg.MaxKPI, stCode, sgCode, spCode);

            if (value == null)
            {
                return(null);
            }
            else
            {
                kpi = value.Value;
            }

            if (kpi == -1)  //user entered sure to measure
            {
                var tree = dataService.CreateNewTreeEntry(count);
                tree.STM          = "Y";
                action.TreeRecord = tree;
            }
            else
            {
                action.TreeEstimate = dataService.LogTreeEstimate(count, kpi);
                action.KPI          = kpi;

                var result = ((IThreePSelector)sampler).Sample(kpi);
                if (result != SampleResult.C)
                {
                    var tree = dataService.CreateNewTreeEntry(count);
                    tree.KPI            = kpi;
                    tree.CountOrMeasure = result.ToString();
                    action.TreeRecord   = tree;
                }
            }

            return(action);
        }
        protected Tree TallyStandard(Plot plot, CountTree count)
        {
            var sg      = count.SampleGroup;
            var sgCode  = sg.Code;
            var stCode  = sg.Stratum.Code;
            var sampler = SampleSelectorRepository.GetSamplerBySampleGroupCode(stCode, sgCode);

            Tree tree;
            var  freqSampler = sampler as IFrequencyBasedSelecter;
            // sampler maybe null, if it is treat as zero frequency sampler
            var result = (freqSampler != null) ? freqSampler.Sample() : SampleResult.C;

            tree = DataService.CreateNewTreeEntry(plot, count, (result != SampleResult.C));
            tree.CountOrMeasure = result.ToString();
            tree.TreeCount      = 1;

            return(tree);
        }
        public void SyncDesign_Test_PullCountTree()
        {
            var(master, comps) = MakeFiles(numComponents: 2);

            var compVMs = comps.Select((x, i) => { return(new ComponentFile()
                {
                    Database = x, Component_CN = i
                }); })
                          .ToArray();

            var comp1 = comps.First();

            var comp1Sg1 = new SampleGroup()
            {
                Code           = "nsg1",
                PrimaryProduct = "01",
                CutLeave       = "C",
                UOM            = "01",
            };

            comp1.Insert(comp1Sg1, keyValue: 1000);

            var compCt1 = new CountTree()
            {
                CuttingUnit_CN = 1,
                SampleGroup_CN = 1000,
                Tally_CN       = 1,
            };

            comp1.Insert(compCt1);

            MergeSyncWorker.SyncDesign(
                master,
                compVMs,
                new System.Threading.CancellationToken(),
                (IProgress <int>)null,
                TestMergeLogWriter);

            var mastCt1 = master.From <CountTree>()
                          .Join("SampleGroup", "USING (SampleGroup_CN)")
                          .Where("Code = @p1").Query("nsg1").FirstOrDefault();

            mastCt1.Should().NotBeNull();
        }
Example #18
0
        //DataService (CreateNewTreeEntry)
        //
        public static TallyAction TallyStandard(CountTree count, ISampleSelector sampleSelecter, ITreeDataService dataService, IDialogService dialogService)
        {
            TallyAction action = new TallyAction(count)
            {
                TreeCount = 1,
            };

            var result = ((IFrequencyBasedSelecter)sampleSelecter).Sample();

            //If we receive nothing from the sampler, we don't have a sample
            if (result != SampleResult.C)//&& (item.IsSelected || item.IsInsuranceItem))
            {
                var tree = dataService.CreateNewTreeEntry(count);
                tree.CountOrMeasure = result.ToString();
                action.TreeRecord   = tree;
            }

            return(action);
        }
Example #19
0
        public void SerializeDeserialize_Test()
        {
            var tallyHistoryCollection = new TallyHistoryCollection(10);

            var count = new CountTree()
            {
                CountTree_CN = 1
            };
            var tree = new Tree()
            {
                Tree_CN = 2
            };
            var treeEstimate = new TreeEstimateDO()
            {
                TreeEstimate_CN = 3
            };
            var kpiValue  = 1234;
            var timeValue = "123";

            tallyHistoryCollection.Add(new TallyAction()
            {
                Count        = count,
                Time         = timeValue,
                KPI          = kpiValue,
                TreeRecord   = tree,
                TreeEstimate = treeEstimate
            });

            var xmlText = tallyHistoryCollection.Serialize();

            var resultCollection = TallyHistoryCollection.Deserialize(xmlText);

            resultCollection.Should().HaveSameCount(tallyHistoryCollection);

            var resultItem = resultCollection.First();

            resultItem.TreeCN.Should().Be(tree.Tree_CN);
            resultItem.TreeEstimateCN.Should().Be(treeEstimate.TreeEstimate_CN);
            resultItem.CountCN.Should().Be(count.CountTree_CN);
            resultItem.KPI.Should().Be(kpiValue);
            resultItem.Time.Should().Be(timeValue);
        }
Example #20
0
        public void GetCountByHotKeyTest()
        {
            var stratum = new Stratum();

            var counts = new CountTree[]
            { new CountTree()
              {
                  Tally = new TallyDO()
                  {
                      Hotkey = "A"
                  }
              },
              new CountTree()
              {
                  Tally = new TallyDO()
                  {
                      Hotkey = "Banana"
                  }
              },
              new CountTree()
              {
                  Tally = new TallyDO()
                  {
                      Hotkey = "cat"
                  }
              } };

            var samplegroups = new SampleGroup[] {
                new SampleGroup()
                {
                    Counts = counts
                }
            };

            stratum.SampleGroups = new List <SampleGroup>(samplegroups);

            stratum.GetCountByHotKey('A').Should().Be(counts[0]);
            stratum.GetCountByHotKey('B').Should().Be(counts[1]);
            stratum.GetCountByHotKey('C').Should().Be(counts[2]);
            stratum.GetCountByHotKey('0').Should().BeNull();
        }
        protected Tree TallyThreeP(Plot plot, CountTree count)
        {
            Tree tree;
            var  sg      = count.SampleGroup;
            var  sgCode  = sg.Code;
            var  stCode  = sg.Stratum.Code;
            var  spCode  = count.TreeDefaultValue.Species;
            var  sampler = SampleSelectorRepository.GetSamplerBySampleGroupCode(stCode, sgCode);

            int kpi   = 0;
            int?value = _dialogService.AskKPI((int)sg.MinKPI, (int)sg.MaxKPI, stCode, sgCode, spCode);

            if (value == null)
            {
                return(null); //user didn't enter valid value
            }
            else
            {
                kpi = value.Value;
            }

            //if kpi == -1 then tree is sure to measure
            if (kpi != -1)
            {
                var result = ((IThreePSelector)sampler).Sample(kpi);

                tree = DataService.CreateNewTreeEntry(plot, count, (result != SampleResult.C));
                tree.CountOrMeasure = result.ToString();
                tree.KPI            = kpi;
            }
            else//tree is sure to measure
            {
                tree     = DataService.CreateNewTreeEntry(plot, count, true);
                tree.STM = "Y";
            }

            tree.TreeCount = 1;

            return(tree);
        }
        void ShowTallySettings(CountTree count)
        {
            this.ViewLogicController.SavePlotTrees();
            try
            {
                count.Save();
                var countDataService = new CountTreeDataService(DataService.DataStore, count);
                using (FormTallySettings view = new FormTallySettings(countDataService, SampleSelectorRepository))
                {
#if !NetCF
                    view.ShowDialog(this);
#else
                    view.ShowDialog();
#endif
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex);
                return;
            }
        }
Example #23
0
        public void TallyThreePTest_STM()
        {
            int expectedKPI = -1;//when kpi is -1, kpi entered was STM
            int minKPI      = 101;
            int maxKPI      = 102;

            var dialogServiceMock = new Mock <IDialogService>();

            dialogServiceMock.Setup(ds => ds.AskKPI(It.Is <int>(x => x == minKPI), It.Is <int>(x => x == maxKPI), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()))
            .Returns(expectedKPI);

            var sg = new SampleGroup()
            {
                MinKPI = minKPI, MaxKPI = maxKPI
            };

            var count = new CountTree()
            {
                TreeCount = 0, SumKPI = 0
            };
            var sampleSelector = new FMSC.Sampling.ThreePSelecter(1, 0);

            var expectedTree    = new Tree();
            var dataServiceMock = new Moq.Mock <ITreeDataService>();

            dataServiceMock.Setup(ds => ds.CreateNewTreeEntry(It.IsAny <CountTree>())).Returns(expectedTree);

            var result = FormDataEntryLogic.TallyThreeP(count, sampleSelector, sg, dataServiceMock.Object, dialogServiceMock.Object);

            result.Should().NotBeNull();
            result.TreeRecord.Should().BeSameAs(expectedTree);
            result.Count.Should().BeSameAs(count);
            result.KPI.Should().Be(0);
            result.TreeCount.Should().Be(1);

            expectedTree.CountOrMeasure.Should().BeNull();
            expectedTree.STM = "Y";
        }
Example #24
0
        public void TallyStandardTest()
        {
            var count = new CountTree()
            {
                TreeCount = 0
            };

            FMSC.Sampling.IFrequencyBasedSelecter sampleSelector = new FMSC.Sampling.SystematicSelecter(1, 0, true);//100%

            var expectedTree = new Tree();

            var dataServiceMock = new Moq.Mock <ITreeDataService>();

            dataServiceMock.Setup(ds => ds.CreateNewTreeEntry(It.IsAny <CountTree>())).Returns(expectedTree);

            var dialogServiceMock = new Mock <IDialogService>();
            //dialogServiceMock.Setup()

            var result = FormDataEntryLogic.TallyStandard(count, sampleSelector, dataServiceMock.Object, dialogServiceMock.Object);

            result.Should().NotBeNull();
            result.TreeRecord.Should().BeSameAs(expectedTree);
            result.Count.Should().BeSameAs(count);
            result.TreeCount.Should().Be(1);
            result.KPI.Should().Be(0);

            expectedTree.CountOrMeasure.Should().Be("M");

            sampleSelector = new ZeroPCTSelector();//0%

            sampleSelector.Sample().Should().Be(SampleResult.C);

            result = FormDataEntryLogic.TallyStandard(count, sampleSelector, dataServiceMock.Object, dialogServiceMock.Object);
            result.TreeRecord.Should().BeNull();
            result.TreeCount.Should().Be(1);
            result.KPI.Should().Be(0);
        }
Example #25
0
 static void Main(String[] args) {
     string[] strs;
     strs = Console.ReadLine().Split(' ');
     var n = int.Parse(strs[0]);
     var t = int.Parse(strs[1]);
     var children = new List<int>[n + 1];
     var hasParent = new bool[n + 1];
     
     for (var i = 1; i < n; ++i)
     {
         strs = Console.ReadLine().Split(' ');
         var parent = int.Parse(strs[0]);
         var child = int.Parse(strs[1]);
         if (children[parent] == null)
         {
             children[parent] = new List<int>();
         }
         children[parent].Add(child);
         hasParent[child] = true;
     }
     
     int root = 0;
     for (var i = 1; i <= n; ++i)
     {
         if (!hasParent[i])
         {
             root = i;
             break;
         }
     }
     
     long result = 0;
     var visitedNodes = new CountTree(1, n);
     visitedNodes.Add(root);
     var stack = new Stack<StackElement>();
     stack.Push(new StackElement { Lable = root, CurrentChildIndex = 0 });
     
     while (stack.Count > 0)
     {
         var node = stack.Peek();
         var childrenCount = children[node.Lable] == null ? 0 : children[node.Lable].Count; 
         if (node.CurrentChildIndex >= childrenCount)
         {
             visitedNodes.Remove(node.Lable);
             stack.Pop();
         }
         else
         {
             var nextNode = children[node.Lable][node.CurrentChildIndex];
             var lower = nextNode - t;
             var upper = nextNode + t;
             result += visitedNodes.GetCountLessThanOrEqualTo(upper) - visitedNodes.GetCountLessThanOrEqualTo(lower - 1);
             ++node.CurrentChildIndex;
             visitedNodes.Add(nextNode);
             stack.Push(new StackElement { Lable = nextNode, CurrentChildIndex = 0 });
         }
     }
     
     Console.WriteLine(result);
 }
Example #26
0
 public void Test_4()
 {
     tree = new CountTree("../../example_4.txt");
     Assert.AreEqual(tree.Count(), 4);
 }
Example #27
0
        public void RecursiveDeleteStratum()
        {
            using (var database = new DAL())
            {
                var unit = new CuttingUnit()
                {
                    Code = "u1"
                };
                database.Insert(unit);

                var stratum = new Stratum()
                {
                    Code = "st1", Method = "STR"
                };
                database.Insert(stratum);

                var unitStratum = new CuttingUnitStratum()
                {
                    CuttingUnit_CN = unit.CuttingUnit_CN.Value, Stratum_CN = stratum.Stratum_CN.Value
                };
                database.Insert(unitStratum);

                var sampleGroup = new SampleGroup()
                {
                    Stratum_CN = stratum.Stratum_CN.Value, Code = "sg1", CutLeave = "C", UOM = "01", PrimaryProduct = "01"
                };
                database.Insert(sampleGroup);

                var samplerState = new SamplerState()
                {
                    SampleGroup_CN = sampleGroup.SampleGroup_CN.Value
                };
                database.Insert(samplerState);

                var countTree = new CountTree()
                {
                    CuttingUnit_CN = unit.CuttingUnit_CN.Value, SampleGroup_CN = sampleGroup.SampleGroup_CN.Value
                };
                database.Insert(countTree);

                var treeEstimate = new TreeEstimate()
                {
                    CountTree_CN = countTree.CountTree_CN
                };
                database.Insert(treeEstimate);

                var stratumStats = new StratumStats()
                {
                    Stratum_CN = stratum.Stratum_CN.Value, Code = "ss1"
                };
                database.Insert(stratumStats);

                var sampleGroupStats = new SampleGroupStats()
                {
                    StratumStats_CN = stratumStats.StratumStats_CN.Value, Code = "sgs1"
                };
                database.Insert(sampleGroupStats);

                var stDO = database.Query <StratumDO>("SELECT * FROM Stratum;").First();
                stDO.Should().NotBeNull();

                var plot = new Plot()
                {
                    CuttingUnit_CN = unit.CuttingUnit_CN.Value,
                    Stratum_CN     = stratum.Stratum_CN.Value,
                    PlotNumber     = 1,
                };
                database.Insert(plot);

                var tree = new Tree()
                {
                    CuttingUnit_CN = unit.CuttingUnit_CN.Value,
                    Stratum_CN     = stratum.Stratum_CN.Value,
                    SampleGroup_CN = sampleGroup.SampleGroup_CN.Value,
                    Plot_CN        = plot.Plot_CN.Value,
                    TreeNumber     = 1,
                    Species        = "1",
                };
                database.Insert(tree);

                var log = new Log()
                {
                    Tree_CN   = tree.Tree_CN.Value,
                    LogNumber = "1",
                };
                database.Insert(log);

                database.HasForeignKeyErrors().Should().BeFalse();

                StratumDO.RecursiveDeleteStratum(stDO);

                stDO.Invoking(x => x.Delete()).Should().NotThrow();

                database.GetRowCount("Stratum", "WHERE Stratum_CN = @p1", stratum.Stratum_CN)
                .Should().Be(0);
                database.GetRowCount("Plot", "WHERE Plot_CN = @p1", plot.Plot_CN)
                .Should().Be(0);
                database.GetRowCount("Tree", "WHERE Tree_CN = @p1", tree.Tree_CN)
                .Should().Be(0);
                database.GetRowCount("Log", "WHERE Log_CN = @p1", log.Log_CN)
                .Should().Be(0);
                database.GetRowCount("StratumStats", "WHERE StratumStats_CN = @p1", stratumStats.StratumStats_CN)
                .Should().Be(0);
                database.GetRowCount("SampleGroupStats", "WHERE SampleGroupStats_CN = @p1", sampleGroupStats.SampleGroupStats_CN)
                .Should().Be(0);

                var stuff = database.QueryGeneric("PRAGMA FOREIGN_KEY_CHECK");

                //database.Execute($"DELETE FROM SamplerState WHERE SampleGroup_CN IN (SELECT SampleGroup_CN FROM SampleGroup WHERE SampleGroup.Stratum_CN = {stDO.Stratum_CN});");

                //stuff = database.QueryGeneric("PRAGMA FOREIGN_KEY_CHECK");

                database.HasForeignKeyErrors().Should().BeFalse();
            }
        }
Example #28
0
 public void TestLeftNode()
 {
     tree = new CountTree("../../example_3.txt");
     Assert.AreEqual(tree.Root().Left.Action(), 9);
 }
Example #29
0
 public void TestDivide()
 {
     tree = new CountTree("../../example_3.txt");
     Assert.AreEqual(tree.Count(), 3);
 }
Example #30
0
 public void TestSubtractAndMultiply()
 {
     tree = new CountTree("../../example_0.txt");
     Assert.AreEqual(tree.Count(), 0);
 }
Example #31
0
 public void TestSimpleAdd()
 {
     tree = new CountTree("../../example_2.txt");
     Assert.AreEqual(tree.Count(), 2);
 }
Example #32
0
 public Tree CreateNewTreeEntry(CountTree count, bool isMeasure)
 {
     return(CreateNewTreeEntry(count.SampleGroup.Stratum, count.SampleGroup, count.TreeDefaultValue, isMeasure));
 }