Beispiel #1
0
        public void VerifyUpdates_CalculationWithoutOutputs_ReturnsTrue()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            var mainWindow = mocks.Stub <IMainWindow>();
            var gui        = mocks.Stub <IGui>();

            gui.Stub(g => g.MainWindow).Return(mainWindow);
            mocks.ReplayAll();

            plugin.Gui = gui;

            var failureMechanism = new MacroStabilityInwardsFailureMechanism();

            failureMechanism.CalculationsGroup.Children.Add(new MacroStabilityInwardsCalculationScenario());

            var stochasticSoilModelCollection = new MacroStabilityInwardsStochasticSoilModelCollection();
            var context = new MacroStabilityInwardsStochasticSoilModelCollectionContext(stochasticSoilModelCollection, failureMechanism, assessmentSection);

            // Call
            bool updatesVerified = importInfo.VerifyUpdates(context);

            // Assert
            Assert.IsTrue(updatesVerified);
            mocks.VerifyAll();
        }
Beispiel #2
0
        public void VerifyUpdates_CalculationWithoutOutputs_ReturnsTrue()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            var mainWindow = mocks.Stub <IMainWindow>();
            var gui        = mocks.Stub <IGui>();

            gui.Stub(g => g.MainWindow).Return(mainWindow);
            mocks.ReplayAll();

            plugin.Gui = gui;

            var failureMechanism = new PipingFailureMechanism();

            failureMechanism.CalculationsGroup.Children.Add(new SemiProbabilisticPipingCalculationScenario());

            var surfaceLines = new PipingSurfaceLineCollection();
            var context      = new PipingSurfaceLinesContext(surfaceLines, failureMechanism, assessmentSection);

            // Call
            bool updatesVerified = importInfo.VerifyUpdates(context);

            // Assert
            Assert.IsTrue(updatesVerified);
            mocks.VerifyAll();
        }
        public void VerifyUpdates_CalculationWithoutOutputs_ReturnsTrue()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();
            var mainWindow        = mocks.Stub <IMainWindow>();
            var gui = mocks.Stub <IGui>();

            gui.Stub(g => g.MainWindow).Return(mainWindow);
            mocks.ReplayAll();

            using (var plugin = new HeightStructuresPlugin())
            {
                plugin.Gui = gui;

                var failureMechanism = new HeightStructuresFailureMechanism();
                failureMechanism.CalculationsGroup.Children.Add(new StructuresCalculation <HeightStructuresInput>());

                var structures = new StructureCollection <HeightStructure>();
                var context    = new HeightStructuresContext(structures, failureMechanism, assessmentSection);

                ImportInfo importInfo = GetImportInfo(plugin);

                // Call
                bool updatesVerified = importInfo.VerifyUpdates(context);

                // Assert
                Assert.IsTrue(updatesVerified);
                mocks.VerifyAll();
            }
        }
        public void VerifyUpdates_CalculationWithOutputs_AlwaysReturnsExpectedInquiryMessage(bool isActionConfirmed)
        {
            // Setup
            string expectedInquiryMessage = "Als u een vakindeling importeert, dan worden de resultaten van alle probabilistische piping berekeningen verwijderd." +
                                            $"{Environment.NewLine}{Environment.NewLine}Weet u zeker dat u wilt doorgaan?";

            var mocks         = new MockRepository();
            var inquiryHelper = mocks.StrictMock <IInquiryHelper>();

            inquiryHelper.Expect(ih => ih.InquireContinuation(expectedInquiryMessage))
            .Return(isActionConfirmed);
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var failureMechanism      = new PipingFailureMechanism();
            var calculationWithOutput = new ProbabilisticPipingCalculationScenario
            {
                Output = PipingTestDataGenerator.GetRandomProbabilisticPipingOutputWithIllustrationPoints()
            };

            failureMechanism.CalculationsGroup.Children.Add(calculationWithOutput);

            var context = new PipingFailureMechanismSectionsContext(failureMechanism, assessmentSection);
            ImportInfo <PipingFailureMechanismSectionsContext> importInfo = GetImportInfo(inquiryHelper);

            // Call
            bool updatesVerified = importInfo.VerifyUpdates(context);

            // Assert
            Assert.AreEqual(isActionConfirmed, updatesVerified);
            mocks.VerifyAll();
        }
        public void VerifyUpdates_NoProbabilisticCalculations_ReturnsTrue()
        {
            // Setup
            var mocks             = new MockRepository();
            var inquiryHelper     = mocks.StrictMock <IInquiryHelper>();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var failureMechanism = new PipingFailureMechanism();

            failureMechanism.CalculationsGroup.Children.Add(new SemiProbabilisticPipingCalculationScenario
            {
                Output = PipingTestDataGenerator.GetRandomSemiProbabilisticPipingOutput()
            });

            var context = new PipingFailureMechanismSectionsContext(failureMechanism, assessmentSection);
            ImportInfo <PipingFailureMechanismSectionsContext> importInfo = GetImportInfo(inquiryHelper);

            // Call
            bool updatesVerified = importInfo.VerifyUpdates(context);

            // Assert
            Assert.IsTrue(updatesVerified);
            mocks.VerifyAll();
        }
Beispiel #6
0
        public void VerifyUpdates_CalculationWithOutputs_AlwaysReturnsExpectedInquiryMessage(bool isActionConfirmed)
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            var mainWindow = mocks.Stub <IMainWindow>();
            var gui        = mocks.Stub <IGui>();

            gui.Stub(g => g.MainWindow).Return(mainWindow);
            mocks.ReplayAll();

            using (var plugin = new GrassCoverErosionInwardsPlugin())
            {
                plugin.Gui = gui;

                var failureMechanism = new GrassCoverErosionInwardsFailureMechanism();
                failureMechanism.CalculationsGroup.Children.Add(new GrassCoverErosionInwardsCalculation
                {
                    Output = new TestGrassCoverErosionInwardsOutput()
                });

                var dikeProfiles = new DikeProfileCollection();
                var context      = new DikeProfilesContext(dikeProfiles, failureMechanism, assessmentSection);

                ImportInfo importInfo = GetImportInfo(plugin);

                string textBoxMessage = null;
                DialogBoxHandler = (name, wnd) =>
                {
                    var helper = new MessageBoxTester(wnd);
                    textBoxMessage = helper.Text;

                    if (isActionConfirmed)
                    {
                        helper.ClickOk();
                    }
                    else
                    {
                        helper.ClickCancel();
                    }
                };

                // Call
                bool updatesVerified = importInfo.VerifyUpdates(context);

                // Assert
                string expectedInquiryMessage = "Als u dijkprofielen importeert, " +
                                                "dan worden alle rekenresultaten van dit faalmechanisme " +
                                                $"verwijderd.{Environment.NewLine}{Environment.NewLine}Weet u zeker dat u wilt doorgaan?";
                Assert.AreEqual(expectedInquiryMessage, textBoxMessage);
                Assert.AreEqual(isActionConfirmed, updatesVerified);
                mocks.VerifyAll();
            }
        }
Beispiel #7
0
        private void ImportItemsUsingDialog(ImportInfo importInfo, object target)
        {
            string fileDialogResult = inquiryHelper.GetSourceFileLocation(importInfo.FileFilterGenerator.Filter);

            if (fileDialogResult != null && importInfo.VerifyUpdates(target))
            {
                RunImportActivity(importInfo.CreateFileImporter(target, fileDialogResult), importInfo.Name);
            }
            else
            {
                log.InfoFormat(Resources.GuiImportHandler_ImportItemsUsingDialog_Importing_cancelled);
            }
        }
Beispiel #8
0
        public void ImplicitOperator_OptionalDelegatesAndPropertiesSet_ImportInfoFullyConverted()
        {
            // Setup
            var mocks        = new MockRepository();
            var fileImporter = mocks.StrictMock <IFileImporter>();

            mocks.ReplayAll();

            const string name      = "name";
            const string category  = "category";
            var          image     = new Bitmap(16, 16);
            var          generator = new FileFilterGenerator();

            var info = new ImportInfo <int>
            {
                CreateFileImporter = (data, filePath) => fileImporter,
                IsEnabled          = data => false,
                Name                = name,
                Category            = category,
                Image               = image,
                FileFilterGenerator = generator,
                VerifyUpdates       = i => true
            };

            // Precondition
            Assert.IsInstanceOf <ImportInfo <int> >(info);

            // Call
            ImportInfo convertedInfo = info;

            // Assert
            Assert.IsInstanceOf <ImportInfo>(convertedInfo);
            Assert.AreEqual(typeof(int), convertedInfo.DataType);
            Assert.IsNotNull(convertedInfo.CreateFileImporter);
            Assert.AreSame(fileImporter, convertedInfo.CreateFileImporter(12, ""));
            Assert.IsNotNull(convertedInfo.IsEnabled);
            Assert.IsFalse(convertedInfo.IsEnabled(12));
            Assert.AreEqual(name, info.Name);
            Assert.AreEqual(category, info.Category);
            Assert.AreSame(image, info.Image);
            Assert.AreEqual(generator, info.FileFilterGenerator);
            Assert.IsNotNull(info.VerifyUpdates);
            Assert.IsTrue(convertedInfo.VerifyUpdates(12));

            mocks.VerifyAll();
        }
Beispiel #9
0
        public void VerifyUpdates_CalculationWithoutOutputs_ReturnsTrue()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            var  mainWindow = mocks.Stub <IMainWindow>();
            IGui gui        = StubFactory.CreateGuiStub(mocks);

            gui.Stub(g => g.MainWindow).Return(mainWindow);

            var calculationWithoutOutput = mocks.Stub <ICalculation>();

            calculationWithoutOutput.Stub(calc => calc.HasOutput).Return(false);

            var failureMechanism = mocks.Stub <ICalculatableFailureMechanism>();

            failureMechanism.Stub(fm => fm.Calculations).Return(new[]
            {
                calculationWithoutOutput
            });

            mocks.ReplayAll();

            var foreshoreProfiles = new ForeshoreProfileCollection();
            var context           = new ForeshoreProfilesContext(foreshoreProfiles, failureMechanism, assessmentSection);

            using (var plugin = new RiskeerPlugin())
            {
                plugin.Gui = gui;

                ImportInfo importInfo = GetImportInfo(plugin);

                // Call
                bool updatesVerified = importInfo.VerifyUpdates(context);

                // Assert
                Assert.IsTrue(updatesVerified);
            }

            mocks.VerifyAll();
        }
Beispiel #10
0
        public void VerifyUpdates_CalculationWithOutputs_AlwaysReturnInquiryMessage(bool isActionConfirmed)
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            var  mainWindow = mocks.Stub <IMainWindow>();
            IGui gui        = StubFactory.CreateGuiStub(mocks);

            gui.Stub(g => g.MainWindow).Return(mainWindow);

            var calculationWithoutOutput = mocks.Stub <ICalculation>();

            calculationWithoutOutput.Stub(calc => calc.HasOutput).Return(true);

            var failureMechanism = mocks.Stub <ICalculatableFailureMechanism>();

            failureMechanism.Stub(fm => fm.Calculations).Return(new[]
            {
                calculationWithoutOutput
            });
            mocks.ReplayAll();

            var foreshoreProfiles = new ForeshoreProfileCollection();
            var context           = new ForeshoreProfilesContext(foreshoreProfiles, failureMechanism, assessmentSection);

            string textBoxMessage = null;

            DialogBoxHandler = (name, wnd) =>
            {
                var helper = new MessageBoxTester(wnd);
                textBoxMessage = helper.Text;

                if (isActionConfirmed)
                {
                    helper.ClickOk();
                }
                else
                {
                    helper.ClickCancel();
                }
            };

            using (var plugin = new RiskeerPlugin())
            {
                plugin.Gui = gui;

                ImportInfo importInfo = GetImportInfo(plugin);

                // Call
                bool updatesVerified = importInfo.VerifyUpdates(context);

                // Assert
                Assert.AreEqual(isActionConfirmed, updatesVerified);
                string expectedInquiryMessage = "Als u voorlandprofielen importeert, " +
                                                "dan worden de  resultaten van alle berekeningen in dit faalmechanisme " +
                                                "die voorlandprofielen gebruiken verwijderd." +
                                                $"{Environment.NewLine}{Environment.NewLine}Weet u zeker dat u wilt doorgaan?";
                Assert.AreEqual(expectedInquiryMessage, textBoxMessage);
            }

            mocks.VerifyAll();
        }