コード例 #1
0
        public ControlTreeDataGrid(IDataEntryDataService dataService
                                   , ApplicationSettings appSettings
                                   , FormDataEntryLogic dataEntryController)
            : this()
        {
            DataService         = dataService;
            DataEntryController = dataEntryController;
            AppSettings         = appSettings;

            DataGridTableStyle tableStyle = dataService.InitializeTreeColumns(this);

            _speciesColumn    = tableStyle.GridColumnStyles["TreeDefaultValue"] as EditableComboBoxColumn;
            _sgColumn         = tableStyle.GridColumnStyles["SampleGroup"] as EditableComboBoxColumn;
            _stratumColumn    = tableStyle.GridColumnStyles["Stratum"] as EditableComboBoxColumn;
            _treeNumberColumn = tableStyle.GridColumnStyles["TreeNumber"] as EditableTextBoxColumn;
            _initialsColoumn  = tableStyle.GridColumnStyles["Initials"] as EditableComboBoxColumn;
            _logsColumn       = tableStyle.GridColumnStyles["LogCountActual"] as DataGridButtonColumn;
            _kpiColumn        = tableStyle.GridColumnStyles["KPI"] as EditableTextBoxColumn;
            _errorsColumn     = tableStyle.GridColumnStyles["Errors"] as DataGridTextBoxColumn;

            Settings_CruisersChanged(null, null);//initialize initials column

            if (_logsColumn != null)
            {
                _logsColumn.Click += this.LogsClicked;
                LogColumnVisable   = DataService.EnableLogGrading;
            }
            if (_stratumColumn != null)
            {
                _stratumColumn.DataSource = dataService.TreeStrata;
            }
        }
コード例 #2
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();
        }
コード例 #3
0
 public LayoutTreeBased(IDataEntryDataService dataService,
                        ISampleSelectorRepository sampleSelectorRepository,
                        ApplicationSettings appSettings,
                        FormDataEntryLogic dataEntryController)
     : this()
 {
     Initialize(dataService,
                sampleSelectorRepository,
                appSettings,
                dataEntryController,
                _leftContentPanel);
 }
コード例 #4
0
        protected void Initialize(IDataEntryDataService dataService,
                                  ISampleSelectorRepository sampleSelectorRepository,
                                  ApplicationSettings appSettings,
                                  FormDataEntryLogic dataEntryController,
                                  Panel strataViewContainer)
        {
            SampleSelectorRepository = sampleSelectorRepository;
            AppSettings         = appSettings;
            StrataViewContainer = strataViewContainer;
            DataEntryController = dataEntryController;
            DataService         = dataService;

            InitializeStrataViews();
        }
コード例 #5
0
        public ControlTreeDataGrid(IDataEntryDataService dataService
                                   , ApplicationSettings appSettings
                                   , FormDataEntryLogic dataEntryController) : this()
        {
            DataService         = dataService;
            DataEntryController = dataEntryController;
            AppSettings         = appSettings;

            var fontWidth = (int)Math.Ceiling(CreateGraphics().MeasureString("_", Font).Width);

            var columns = DataService.MakeTreeColumns(fontWidth);

            base.Columns.AddRange(columns.ToArray());

            _speciesColumn      = base.Columns["TreeDefaultValue"] as DataGridViewComboBoxColumn;
            _sgColumn           = base.Columns["SampleGroup"] as DataGridViewComboBoxColumn;
            _stratumColumn      = base.Columns["Stratum"] as DataGridViewComboBoxColumn;
            _treeNumberColumn   = base.Columns["TreeNumber"] as DataGridViewTextBoxColumn;
            _initialsColoumn    = base.Columns["Initials"] as DataGridViewComboBoxColumn;
            _errorMessageColumn = base.Columns["Error"] as DataGridViewTextBoxColumn;
            _logsColumn         = base.Columns["Logs"] as DataGridViewButtonColumn;

            if (_speciesColumn != null)
            {
                _speciesColumn.DataSource = DataService.GetTreeDefaultValuesAll().ToList();
            }
            if (_sgColumn != null)
            {
                _sgColumn.DataSource = DataService.TreeStrata.SelectMany(st => st.SampleGroups).ToList();
            }
            if (_stratumColumn != null)
            {
                _stratumColumn.DataSource = DataService.TreeStrata;
            }

            if (_logsColumn != null)
            {
                //cell click doesn't need to be hooked up here. see ControlTreeDataGrid_CellClick method
                _logsColumn.Visible = DataService.EnableLogGrading;
            }

            Settings_CruisersChanged(null, null);//initialize initials column
        }
コード例 #6
0
        protected void InitializeCommon(IApplicationController controller,
                                        ApplicationSettings appSettings,
                                        IDataEntryDataService dataService,
                                        ISampleSelectorRepository sampleSelectorRepository)
        {
            KeyPreview = true;

            Controller  = controller;
            DataService = dataService;
            AppSettings = appSettings;
            SampleSelectorRepository = sampleSelectorRepository;

            LogicController = new FormDataEntryLogic(Controller,
                                                     DialogService.Instance,
                                                     SoundService.Instance,
                                                     DataService,
                                                     AppSettings,
                                                     this,
                                                     sampleSelectorRepository);

            InitializePageContainer();
        }
コード例 #7
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";
        }
コード例 #8
0
        public DataEntryTests()
        {
            _pathToFile = System.IO.Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.Personal)
                                                 , "testDataStore.cruise");

            if (System.IO.File.Exists(_pathToFile))
            {
                System.IO.File.Delete(_pathToFile);
            }

            _dataStore     = SetupDataStore();
            _dialogService = new DialogServiceMock();
            _soundService  = new SoundServiceMock();
            var dataService = new IDataEntryDataService("01", _dataStore);
            var appSettings = new ApplicationSettings();

            _de = new FormDataEntryLogic(_controller
                                         , _dialogService
                                         , _soundService
                                         , dataService
                                         , appSettings
                                         , _view);
        }
コード例 #9
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);
        }
コード例 #10
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>()));
                    }
                }
            }
        }