예제 #1
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());
        }
예제 #2
0
        //[InlineData(0,0, "C", false, false)]//frequency of 0 is not allowed and breaks the OnTally
        public void OnTallyTest_STR(int frequency, int insuranceFreq, string resultCountMeasure, bool enableCruiserPopup, bool enterMeasureTreeData)
        {
            using (var ds = CreateDatastore(CruiseDAL.Schema.CruiseMethods.STR, frequency, insuranceFreq))
            {
                var dataService = new IDataEntryDataService("01", ds);

                var count = ds.From <CountTree>().Read().Single();

                var tallyHistory = new List <TallyAction>();

                var appSettingsMock = new Mock <IApplicationSettings>();
                appSettingsMock.Setup(x => x.EnableCruiserPopup).Returns(enableCruiserPopup);
                appSettingsMock.Setup(x => x.EnableAskEnterTreeData).Returns(enterMeasureTreeData);

                var dataEntryViewMock = new Mock <IDataEntryView>();
                var dialogServiceMock = new Mock <IDialogService>();
                dialogServiceMock.Setup(x => x.AskYesNo(It.Is <string>(s => s == "Would you like to enter tree data now?"), It.IsAny <string>(), It.IsAny <bool>()))
                .Returns(enterMeasureTreeData);

                var soundServiceMock = new Mock <ISoundService>();

                var samplerRepo = new Mock <ISampleSelectorRepository>();
                samplerRepo.Setup(x => x.GetSamplerBySampleGroupCode(It.IsAny <string>(), It.IsAny <string>()))
                .Returns(new FMSC.Sampling.SystematicSelecter(frequency, insuranceFreq, false));

                FormDataEntryLogic.OnTally(count, dataService, tallyHistory,
                                           appSettingsMock.Object,
                                           dataEntryViewMock.Object,
                                           dialogServiceMock.Object,
                                           soundServiceMock.Object,
                                           samplerRepo.Object);

                tallyHistory.Should().HaveCount(1);
                var tallyAction = tallyHistory.Single();

                var treeCount = ds.ExecuteScalar <int>("SELECT Sum(TreeCount) FROM CountTree;");
                treeCount.Should().Be(1);

                // verify SingnalTally was called
                soundServiceMock.Verify(x => x.SignalTally(It.IsAny <bool>()));

                if (resultCountMeasure == "M" || resultCountMeasure == "I")
                {
                    tallyAction.TreeRecord.Should().NotBeNull();

                    dataService.NonPlotTrees.Should().HaveCount(1);

                    var tree = ds.From <Tree>().Read().Single();
                    tree.Should().NotBeNull();
                    tree.CountOrMeasure.Should().Be(resultCountMeasure);

                    if (resultCountMeasure == "M")
                    {
                        soundServiceMock.Verify(x => x.SignalMeasureTree());
                    }
                    else
                    {
                        soundServiceMock.Verify(x => x.SignalInsuranceTree());
                    }

                    if (enterMeasureTreeData)
                    {
                        dataEntryViewMock.Verify(v => v.GotoTreePage());//verify GoToTreePage was called
                    }

                    if (enableCruiserPopup)
                    {
                        dialogServiceMock.Verify(x => x.AskCruiser(It.IsNotNull <Tree>()));
                    }
                    else
                    {
                        dialogServiceMock.Verify(x => x.ShowMessage(It.Is <string>(s => s.Contains("Tree #")), It.IsAny <string>()));
                    }
                }
            }
        }