コード例 #1
0
        public void CreateInstance_WaveImpactAsphaltCoverWaveConditionsInputContext_ReturnViewWithStylingApplied()
        {
            // Setup
            var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation();
            var context     = new WaveImpactAsphaltCoverWaveConditionsInputContext(
                new WaveConditionsInput(),
                calculation,
                new AssessmentSectionStub(),
                Array.Empty <ForeshoreProfile>());

            // Call
            var view = (WaveConditionsInputView)info.CreateInstance(context);

            // Assert
            ChartDataCollection chartData = view.Chart.Data;

            var lowerBoundaryRevetmentChartData = (ChartLineData)chartData.Collection.ElementAt(lowerBoundaryRevetmentChartDataIndex);
            var upperBoundaryRevetmentChartData = (ChartLineData)chartData.Collection.ElementAt(upperBoundaryRevetmentChartDataIndex);
            var revetmentBaseChartData          = (ChartLineData)chartData.Collection.ElementAt(revetmentBaseChartDataIndex);
            var revetmentChartData = (ChartLineData)chartData.Collection.ElementAt(revetmentChartDataIndex);

            Color revetmentLineColor = Color.Gray;

            Assert.AreEqual(revetmentLineColor, lowerBoundaryRevetmentChartData.Style.Color);
            Assert.AreEqual(revetmentLineColor, upperBoundaryRevetmentChartData.Style.Color);
            Assert.AreEqual(Color.FromArgb(120, revetmentLineColor), revetmentBaseChartData.Style.Color);
            Assert.AreEqual(revetmentLineColor, revetmentChartData.Style.Color);
        }
コード例 #2
0
        public void CreateInstance_WithContext_SetsExpectedProperties()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();
            var window            = mocks.Stub <IMainWindow>();
            var gui = mocks.Stub <IGui>();

            gui.Stub(g => g.MainWindow).Return(window);
            gui.Stub(g => g.ViewHost).Return(mocks.Stub <IViewHost>());
            mocks.ReplayAll();

            var failureMechanism = new DuneErosionFailureMechanism();
            var context          = new DuneLocationCalculationsForUserDefinedTargetProbabilityContext(new DuneLocationCalculationsForTargetProbability(0.1),
                                                                                                      failureMechanism,
                                                                                                      assessmentSection);

            using (var plugin = new DuneErosionPlugin())
            {
                ViewInfo info = GetInfo(plugin);

                plugin.Gui = gui;
                plugin.Activate();

                // Call
                using (var view = info.CreateInstance(context) as DuneLocationCalculationsView)
                {
                    // Assert
                    Assert.AreSame(assessmentSection, view.AssessmentSection);
                    Assert.AreSame(failureMechanism, view.FailureMechanism);
                }
            }

            mocks.VerifyAll();
        }
コード例 #3
0
        private static IView CreateViewForData(object data, ViewInfo viewInfo)
        {
            IView view = viewInfo.CreateInstance(data);

            view.Data = viewInfo.GetViewData(data);

            viewInfo.AfterCreate(view, data);

            return(view);
        }
コード例 #4
0
        public void CreateInstance_WithContext_ReturnsAssessmentSectionReferenceLineView()
        {
            // Setup
            var context = new CalculationsStateRootContext(new AssessmentSection(AssessmentSectionComposition.Dike));

            // Call
            IView view = info.CreateInstance(context);

            // Assert
            Assert.IsInstanceOf <AssessmentSectionReferenceLineView>(view);
        }
コード例 #5
0
        public void CreateInstance_WithContext_ReturnsAssessmentSectionExtendedView()
        {
            // Setup
            var context = new RegistrationStateRootContext(new AssessmentSection(AssessmentSectionComposition.Dike));

            // Call
            IView view = info.CreateInstance(context);

            // Assert
            Assert.IsInstanceOf <AssessmentSectionExtendedView>(view);
        }
コード例 #6
0
        public void CreateInstance_WithContext_CreatesInstanceOfViewType()
        {
            // Setup
            var            calculation = new GrassCoverErosionInwardsCalculation();
            TOutputContext context     = GetContext(calculation);

            // Call
            IView view = info.CreateInstance(context);

            // Assert
            Assert.IsInstanceOf <TView>(view);
        }
コード例 #7
0
        public void CreateInstance_WithContext_SetsExpectedViewProperties()
        {
            // Setup
            AssessmentSection assessmentSection = CreateAssessmentSection();
            var context = new AssemblyResultPerSectionMapContext(assessmentSection);

            // Call
            var view = (AssemblyResultPerSectionMapView)info.CreateInstance(context);

            // Assert
            Assert.AreSame(assessmentSection, view.AssessmentSection);
        }
コード例 #8
0
        public void CreateInstance_WithContext_SetsExpectedViewProperties()
        {
            // Setup
            var random            = new Random(21);
            var assessmentSection = new AssessmentSection(random.NextEnumValue <AssessmentSectionComposition>());
            var context           = new AssemblyResultPerSectionContext(assessmentSection);

            // Call
            var view = (AssemblyResultPerSectionView)info.CreateInstance(context);

            // Assert
            Assert.AreSame(assessmentSection, view.AssessmentSection);
        }
コード例 #9
0
        public void CreateInstance_ViewTypeHasDefaultConstructor_ReturnView()
        {
            // Setup
            var viewInfo = new ViewInfo <int, string, StringView>();
            int data     = new Random(21).Next();

            // Call
            StringView view = viewInfo.CreateInstance(data);

            // Assert
            Assert.IsNotNull(view);
            Assert.IsNull(view.Data);
        }
コード例 #10
0
        public void CreateInstance_WithContext_ReturnsView()
        {
            // Setup
            var failureMechanism  = new MacroStabilityInwardsFailureMechanism();
            var calculationsGroup = new CalculationGroup();
            var context           = new MacroStabilityInwardsScenariosContext(calculationsGroup, failureMechanism);

            // Call
            IView view = info.CreateInstance(context);

            // Assert
            Assert.IsInstanceOf <MacroStabilityInwardsScenariosView>(view);
        }
コード例 #11
0
        public void CreateInstance_WithContext_ReturnsHeightStructuresScenariosView()
        {
            // Setup
            var group   = new CalculationGroup();
            var context = new HeightStructuresScenariosContext(group, new HeightStructuresFailureMechanism());

            // Call
            using (IView view = info.CreateInstance(context))
            {
                // Assert
                Assert.IsInstanceOf <HeightStructuresScenariosView>(view);
                Assert.AreSame(group, view.Data);
            }
        }
        public void CreateInstance_WithContext_ReturnWaveImpactAsphaltCoverFailureMechanismView()
        {
            // Setup
            var assessmentSection = new AssessmentSectionStub();
            var failureMechanism  = new WaveImpactAsphaltCoverFailureMechanism();

            var context = new WaveImpactAsphaltCoverFailureMechanismContext(failureMechanism, assessmentSection);

            // Call
            var view = (WaveImpactAsphaltCoverFailureMechanismView)info.CreateInstance(context);

            // Assert
            Assert.AreSame(failureMechanism, view.FailureMechanism);
            Assert.AreSame(assessmentSection, view.AssessmentSection);
        }
        public void CreateInstance_WithContext_ReturnMacroStabilityInwardsFailureMechanismView()
        {
            // Setup
            var assessmentSection = new AssessmentSectionStub();
            var failureMechanism  = new MacroStabilityInwardsFailureMechanism();

            var context = new MacroStabilityInwardsFailureMechanismContext(failureMechanism, assessmentSection);

            // Call
            var view = (MacroStabilityInwardsFailureMechanismView)info.CreateInstance(context);

            // Assert
            Assert.AreSame(failureMechanism, view.FailureMechanism);
            Assert.AreSame(assessmentSection, view.AssessmentSection);
        }
コード例 #14
0
        public void CreateInstance_WithContext_ReturnsView()
        {
            // Setup
            var failureMechanism = new ClosingStructuresFailureMechanism();
            IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(failureMechanism, mocks);

            var context = new ClosingStructuresFailureMechanismSectionResultContext(
                failureMechanism.SectionResults,
                failureMechanism,
                assessmentSection);

            // Call
            IView view = info.CreateInstance(context);

            // Assert
            Assert.IsInstanceOf <StructuresFailureMechanismResultView <ClosingStructuresFailureMechanism, ClosingStructuresInput> >(view);
            mocks.VerifyAll();
        }
コード例 #15
0
        public void CreateInstance_WithContext_SetsExpectedViewProperties()
        {
            // Setup
            var assessmentSection = new AssessmentSectionStub();
            var context           = new WaterLevelCalculationsForUserDefinedTargetProbabilityContext(new HydraulicBoundaryLocationCalculationsForTargetProbability(0.1),
                                                                                                     assessmentSection);

            using (var plugin = new RiskeerPlugin())
            {
                ViewInfo info = GetViewInfo(plugin);

                // Call
                var view = (DesignWaterLevelCalculationsView)info.CreateInstance(context);

                // Assert
                Assert.AreSame(assessmentSection, view.AssessmentSection);
            }
        }
コード例 #16
0
        public void CreateInstance_WithContext_ReturnsView()
        {
            // Setup
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var failureMechanism  = new PipingFailureMechanism();
            var calculationsGroup = new CalculationGroup();
            var context           = new PipingScenariosContext(calculationsGroup, failureMechanism, assessmentSection);

            // Call
            IView view = info.CreateInstance(context);

            // Assert
            Assert.IsInstanceOf <PipingScenariosView>(view);
            mocks.VerifyAll();
        }
コード例 #17
0
        public void CreateInstance_WithContext_ReturnsView()
        {
            // Setup
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var failureMechanism = new GrassCoverSlipOffOutwardsFailureMechanism();
            var context          = new GrassCoverSlipOffOutwardsFailureMechanismSectionResultContext(
                failureMechanism.SectionResults, failureMechanism, assessmentSection);

            // Call
            IView view = info.CreateInstance(context);

            // Assert
            Assert.IsInstanceOf <NonAdoptableWithProfileProbabilityFailureMechanismResultView <GrassCoverSlipOffOutwardsFailureMechanism> >(view);
            mocks.VerifyAll();
        }
コード例 #18
0
        public void CreateInstance_WithContext_ReturnsView()
        {
            // Setup
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var failureMechanism = new PipingStructureFailureMechanism();
            var context          = new PipingStructureFailureMechanismSectionResultContext(
                failureMechanism.SectionResults, failureMechanism, assessmentSection);

            // Call
            IView view = info.CreateInstance(context);

            // Assert
            Assert.IsInstanceOf <NonAdoptableFailureMechanismResultView <PipingStructureFailureMechanism> >(view);
            mocks.VerifyAll();
        }
コード例 #19
0
        public void CreateInstance_WithContext_ReturnsSpecificFailureMechanismView()
        {
            // Setup
            var assessmentSection = new AssessmentSectionStub();
            var failureMechanism  = new SpecificFailureMechanism();
            var context           = new SpecificFailureMechanismContext(failureMechanism, assessmentSection);

            using (var testForm = new Form())
            {
                // Call
                var view = info.CreateInstance(context) as SpecificFailureMechanismView;

                testForm.Controls.Add(view);
                testForm.Show();

                // Assert
                Assert.AreSame(failureMechanism, view.FailureMechanism);
            }
        }
コード例 #20
0
        public void CreateInstance_WithContext_ReturnsView()
        {
            // Setup
            var failureMechanism = new MacroStabilityInwardsFailureMechanism();

            IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(failureMechanism, mocks);

            mocks.ReplayAll();

            var context = new MacroStabilityInwardsFailureMechanismSectionResultContext(
                failureMechanism.SectionResults, failureMechanism, assessmentSection);

            // Call
            IView view = info.CreateInstance(context);

            // Assert
            Assert.IsInstanceOf <MacroStabilityInwardsFailureMechanismResultView>(view);
            mocks.VerifyAll();
        }
コード例 #21
0
        public void CreateInstance_ViewTypeWithDefaultConstructor_ReturnView()
        {
            // Setup
            var viewInfo = new ViewInfo
            {
                DataType     = typeof(int),
                ViewDataType = typeof(string),
                ViewType     = typeof(StringView)
            };

            int data = new Random(21).Next();

            // Call
            IView view = viewInfo.CreateInstance(data);

            // Assert
            Assert.IsInstanceOf <StringView>(view);
            Assert.IsNull(view.Data);
        }
コード例 #22
0
        public void CreateInstance_WithContext_SetsExpectedDataGridViewData()
        {
            // Setup
            var random = new Random();

            var calculationsForTargetProbability = new HydraulicBoundaryLocationCalculationsForTargetProbability(0.1)
            {
                HydraulicBoundaryLocationCalculations =
                {
                    new HydraulicBoundaryLocationCalculation(new TestHydraulicBoundaryLocation())
                    {
                        Output = new TestHydraulicBoundaryLocationCalculationOutput(random.NextDouble())
                    },
                    new HydraulicBoundaryLocationCalculation(new TestHydraulicBoundaryLocation())
                    {
                        Output = new TestHydraulicBoundaryLocationCalculationOutput(random.NextDouble())
                    }
                }
            };

            var context = new WaterLevelCalculationsForUserDefinedTargetProbabilityContext(calculationsForTargetProbability, new AssessmentSectionStub());

            using (var plugin = new RiskeerPlugin())
            {
                ViewInfo info = GetViewInfo(plugin);

                // Call
                var view = (DesignWaterLevelCalculationsView)info.CreateInstance(context);

                using (var testForm = new Form())
                {
                    testForm.Controls.Add(view);
                    testForm.Show();

                    // Assert
                    DataGridView calculationsDataGridView = ControlTestHelper.GetDataGridView(view, "DataGridView");
                    DataGridViewRowCollection rows        = calculationsDataGridView.Rows;
                    Assert.AreEqual(2, rows.Count);
                    Assert.AreEqual(calculationsForTargetProbability.HydraulicBoundaryLocationCalculations[0].Output.Result.ToString(), rows[0].Cells[waterLevelColumnIndex].FormattedValue);
                    Assert.AreEqual(calculationsForTargetProbability.HydraulicBoundaryLocationCalculations[1].Output.Result.ToString(), rows[1].Cells[waterLevelColumnIndex].FormattedValue);
                }
            }
        }
コード例 #23
0
        public void CreateInstance_WithContext_SetsDataCorrectly()
        {
            // Setup
            var assessmentSection       = new AssessmentSectionStub();
            var calculation             = new MacroStabilityInwardsCalculationScenario();
            var input                   = new MacroStabilityInwardsInput(new MacroStabilityInwardsInput.ConstructionProperties());
            var calculationInputContext = new MacroStabilityInwardsInputContext(input,
                                                                                calculation,
                                                                                Enumerable.Empty <MacroStabilityInwardsSurfaceLine>(),
                                                                                Enumerable.Empty <MacroStabilityInwardsStochasticSoilModel>(),
                                                                                new MacroStabilityInwardsFailureMechanism(),
                                                                                assessmentSection);

            // Call
            IView view = info.CreateInstance(calculationInputContext);

            // Assert
            Assert.AreSame(calculation, view.Data);
            mocks.VerifyAll();
        }
コード例 #24
0
        public void CreateInstance_WithContext_SetsExpectedViewProperties()
        {
            // Setup
            var mocks = new MockRepository();
            IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(null, mocks);

            mocks.ReplayAll();

            var context = new AssessmentSectionAssemblyGroupsContext(assessmentSection);

            using (new AssemblyToolCalculatorFactoryConfig())
            {
                // Call
                var view = (AssessmentSectionAssemblyGroupsView)info.CreateInstance(context);

                // Assert
                Assert.AreSame(assessmentSection.FailureMechanismContribution, view.FailureMechanismContribution);
            }

            mocks.VerifyAll();
        }
コード例 #25
0
        public void CreateInstance_WithData_ReturnFailureMechanismView()
        {
            // Setup
            var assessmentSection = new AssessmentSectionStub();
            var failureMechanism  = new PipingStructureFailureMechanism();

            var context = new PipingStructureFailureMechanismContext(failureMechanism, assessmentSection);

            // Call
            IView view = info.CreateInstance(context);

            // Assert
            Assert.IsInstanceOf <StandAloneFailureMechanismView <PipingStructureFailureMechanism,
                                                                 NonAdoptableFailureMechanismSectionResult> >(view);

            var failureMechanismView = (StandAloneFailureMechanismView <PipingStructureFailureMechanism,
                                                                        NonAdoptableFailureMechanismSectionResult>)view;

            Assert.AreSame(failureMechanism, failureMechanismView.FailureMechanism);
            Assert.AreSame(assessmentSection, failureMechanismView.AssessmentSection);
        }
コード例 #26
0
        public void CreateInstance_WithData_ReturnFailureMechanismView()
        {
            // Setup
            var assessmentSection = new AssessmentSectionStub();
            var failureMechanism  = new GrassCoverSlipOffInwardsFailureMechanism();

            var context = new GrassCoverSlipOffInwardsFailureMechanismContext(failureMechanism, assessmentSection);

            // Call
            IView view = info.CreateInstance(context);

            // Assert
            Assert.IsInstanceOf <StandAloneFailureMechanismView <GrassCoverSlipOffInwardsFailureMechanism,
                                                                 NonAdoptableWithProfileProbabilityFailureMechanismSectionResult> >(view);

            var failureMechanismView = (StandAloneFailureMechanismView <GrassCoverSlipOffInwardsFailureMechanism,
                                                                        NonAdoptableWithProfileProbabilityFailureMechanismSectionResult>)view;

            Assert.AreSame(failureMechanism, failureMechanismView.FailureMechanism);
            Assert.AreSame(assessmentSection, failureMechanismView.AssessmentSection);
        }
コード例 #27
0
        public void ImplicitOperator_WithAllMethodsSet_InfoFullyConverted()
        {
            // Setup
            var viewInfo = new ViewInfo <int, string, StringView>();

            var       stringView = new StringView();
            const int dataObject = 11;

            const string newDescription = "<text>";
            const string newViewName    = "<view name>";
            const string symbol         = "<symbol>";
            var          fontFamily     = new FontFamily();

            string GetViewName(IView view, int o)
            {
                Assert.AreSame(stringView, view);
                Assert.AreEqual(dataObject, o);
                return(newViewName);
            }

            string GetSymbol() => symbol;
            FontFamily GetFontFamily() => fontFamily;

            bool AdditionalDataCheck(int o)
            {
                Assert.AreEqual(dataObject, o);
                return(true);
            }

            string GetViewData(int o)
            {
                Assert.AreEqual(dataObject, o);
                return(o.ToString());
            }

            var afterCreateCalled = false;

            void AfterCreate(IView view, int o)
            {
                Assert.AreSame(stringView, view);
                Assert.AreEqual(dataObject, o);
                afterCreateCalled = true;
            }

            bool CloseForData(IView view, object o)
            {
                Assert.AreSame(stringView, view);
                Assert.AreEqual(dataObject, o);
                return(true);
            }

            viewInfo.Description         = newDescription;
            viewInfo.GetViewName         = (Func <IView, int, string>)GetViewName;
            viewInfo.GetSymbol           = GetSymbol;
            viewInfo.GetFontFamily       = GetFontFamily;
            viewInfo.AdditionalDataCheck = AdditionalDataCheck;
            viewInfo.GetViewData         = GetViewData;
            viewInfo.AfterCreate         = (Action <IView, int>)AfterCreate;
            viewInfo.CloseForData        = (Func <IView, object, bool>)CloseForData;
            viewInfo.CreateInstance      = o => new StringView
            {
                Text = "A"
            };

            // Precondition
            Assert.IsInstanceOf <ViewInfo <int, string, StringView> >(viewInfo);

            // Call
            ViewInfo info = viewInfo;

            // Assert
            Assert.IsInstanceOf <ViewInfo>(info);
            Assert.AreEqual(typeof(int), info.DataType);
            Assert.AreEqual(typeof(string), info.ViewDataType);
            Assert.AreEqual(typeof(StringView), info.ViewType);
            Assert.AreEqual(newDescription, info.Description);
            Assert.AreEqual(newViewName, info.GetViewName(stringView, dataObject));
            Assert.AreEqual(symbol, info.GetSymbol());
            Assert.AreSame(fontFamily, info.GetFontFamily());
            Assert.IsTrue(viewInfo.AdditionalDataCheck(dataObject));
            Assert.AreEqual(dataObject.ToString(), viewInfo.GetViewData(dataObject));
            Assert.AreEqual("A", viewInfo.CreateInstance(dataObject).Text);

            viewInfo.AfterCreate(stringView, dataObject);
            Assert.IsTrue(afterCreateCalled);
        }
コード例 #28
0
        public void CreateInstance_WithContext_SetsExpectedCalculationData()
        {
            // Setup
            var hydraulicBoundaryLocationCalculation = new HydraulicBoundaryLocationCalculation(new TestHydraulicBoundaryLocation());
            var calculationsForTargetProbability     = new HydraulicBoundaryLocationCalculationsForTargetProbability(0.01)
            {
                HydraulicBoundaryLocationCalculations =
                {
                    hydraulicBoundaryLocationCalculation
                }
            };

            var assessmentSection = new AssessmentSectionStub();

            assessmentSection.WaterLevelCalculationsForUserDefinedTargetProbabilities.Add(calculationsForTargetProbability);

            var context = new WaterLevelCalculationsForUserDefinedTargetProbabilityContext(calculationsForTargetProbability, assessmentSection);

            var mockRepository = new MockRepository();
            var guiService     = mockRepository.StrictMock <IHydraulicBoundaryLocationCalculationGuiService>();

            double actualNormValue = double.NaN;
            IEnumerable <HydraulicBoundaryLocationCalculation> performedCalculations = null;

            guiService.Expect(ch => ch.CalculateDesignWaterLevels(null, null, int.MinValue, null)).IgnoreArguments().WhenCalled(
                invocation =>
            {
                performedCalculations = (IEnumerable <HydraulicBoundaryLocationCalculation>)invocation.Arguments[0];
                actualNormValue       = (double)invocation.Arguments[2];
            });

            mockRepository.ReplayAll();

            using (var plugin = new RiskeerPlugin())
            {
                ViewInfo info = GetViewInfo(plugin);

                // Call
                var view = (DesignWaterLevelCalculationsView)info.CreateInstance(context);

                using (var testForm = new Form())
                {
                    view.CalculationGuiService = guiService;
                    testForm.Controls.Add(view);
                    testForm.Show();

                    DataGridView calculationsDataGridView = ControlTestHelper.GetDataGridView(view, "DataGridView");
                    DataGridViewRowCollection rows        = calculationsDataGridView.Rows;
                    rows[0].Cells[calculateColumnIndex].Value = true;

                    view.CalculationGuiService = guiService;
                    var button = new ButtonTester("CalculateForSelectedButton", testForm);

                    button.Click();

                    // Assert
                    Assert.AreEqual(calculationsForTargetProbability.TargetProbability, actualNormValue);
                    Assert.AreSame(hydraulicBoundaryLocationCalculation, performedCalculations.Single());
                }
            }

            mockRepository.VerifyAll();
        }