public void GetAssessmentSectionFromFile_validDirectoryWithEmptyShapeFile_ShowsWarningDialogAndThrowsCriticalFileReadException()
        {
            // Setup
            var mockRepository = new MockRepository();
            var parentDialog   = mockRepository.Stub <IWin32Window>();

            mockRepository.ReplayAll();

            var assessmentSectionFromFileHandler = new AssessmentSectionFromFileHandler(parentDialog);

            string pathValidFolder = Path.Combine(testDataPath, "EmptyShapeFile");

            SetShapeFileDirectory(assessmentSectionFromFileHandler, pathValidFolder);

            string messageText = null;

            DialogBoxHandler = (name, wnd) =>
            {
                var messageBox = new MessageBoxTester(wnd);
                messageText = messageBox.Text;
                messageBox.ClickOk();
            };

            // Call
            void Call() => assessmentSectionFromFileHandler.GetAssessmentSectionFromFile();

            // Assert
            const string expectedMessage = "Er kunnen geen trajecten gelezen worden uit het shapebestand.";
            var          exception       = Assert.Throws <CriticalFileValidationException>(Call);

            Assert.AreEqual(expectedMessage, exception.Message);
            Assert.AreEqual(expectedMessage, messageText);
            mockRepository.VerifyAll();
        }
        public void GetAssessmentSectionFromFile_SecondRowSelectedOkClicked_ReturnsSecondReadAssessmentSection()
        {
            // Setup
            var mockRepository = new MockRepository();
            var parentDialog   = mockRepository.Stub <IWin32Window>();

            mockRepository.ReplayAll();

            var assessmentSectionFromFileHandler = new AssessmentSectionFromFileHandler(parentDialog);

            string pathValidFolder = Path.Combine(testDataPath, "ValidShapeFile");

            SetShapeFileDirectory(assessmentSectionFromFileHandler, pathValidFolder);

            var rowCount = 0;

            DialogBoxHandler = (name, wnd) =>
            {
                var selectionDialog = (ReferenceLineMetaSelectionDialog) new FormTester(name).TheObject;
                var grid            = (DataGridViewControl) new ControlTester("ReferenceLineMetaDataGridViewControl", selectionDialog).TheObject;
                rowCount = grid.Rows.Count;
                DataGridView dataGridView = grid.Controls.OfType <DataGridView>().First();
                dataGridView[0, 1].Selected = true;

                new ButtonTester("Ok", selectionDialog).Click();
            };

            // Call
            AssessmentSection assessmentSection = assessmentSectionFromFileHandler.GetAssessmentSectionFromFile();

            // Assert
            Assert.AreEqual(3, rowCount);
            AssertAssessmentSection(TestAssessmentSection2_1(), assessmentSection);
            mockRepository.VerifyAll();
        }
        public void GetAssessmentSectionFromFile_ValidDirectoryLowLimitSelectedOkClicked_ReturnsFirstReadAssessmentSectionWithLowLimit()
        {
            // Setup
            var mockRepository = new MockRepository();
            var parentDialog   = mockRepository.Stub <IWin32Window>();

            mockRepository.ReplayAll();

            var assessmentSectionFromFileHandler = new AssessmentSectionFromFileHandler(parentDialog);

            string pathValidFolder = Path.Combine(testDataPath, "ValidShapeFile");

            SetShapeFileDirectory(assessmentSectionFromFileHandler, pathValidFolder);

            DialogBoxHandler = (name, wnd) =>
            {
                var selectionDialog          = (ReferenceLineMetaSelectionDialog) new FormTester(name).TheObject;
                var lowLimitValueRadioButton = (RadioButton) new RadioButtonTester("MaximumAllowableFloodingProbabilityRadioButton", selectionDialog).TheObject;
                lowLimitValueRadioButton.Checked = true;
                new ButtonTester("Ok", selectionDialog).Click();
            };

            // Call
            AssessmentSection assessmentSection = assessmentSectionFromFileHandler.GetAssessmentSectionFromFile();

            // Assert
            AssertAssessmentSection(TestAssessmentSection1_2(false), assessmentSection);
            mockRepository.VerifyAll();
        }
        public void GetAssessmentSectionFromFile_ValidDirectoryUserClicksCancel_ReturnsNull()
        {
            // Setup
            var mockRepository = new MockRepository();
            var parentDialog   = mockRepository.Stub <IWin32Window>();

            mockRepository.ReplayAll();

            var assessmentSectionFromFileHandler = new AssessmentSectionFromFileHandler(parentDialog);

            string pathValidFolder = Path.Combine(testDataPath, "ValidShapeFile");

            SetShapeFileDirectory(assessmentSectionFromFileHandler, pathValidFolder);

            DialogBoxHandler = (name, wnd) =>
            {
                var selectionDialog = (ReferenceLineMetaSelectionDialog) new FormTester(name).TheObject;
                new ButtonTester("Cancel", selectionDialog).Click();
            };

            // Call
            AssessmentSection assessmentSection = assessmentSectionFromFileHandler.GetAssessmentSectionFromFile();

            // Assert
            Assert.IsNull(assessmentSection);
            mockRepository.VerifyAll();
        }
        private static void SetShapeFileDirectory(AssessmentSectionFromFileHandler handler, string nonExistingFolder)
        {
            const string privateShapeFileDirectoryName = "shapeFileDirectory";
            Type         commandHandlerType            = handler.GetType();
            FieldInfo    fieldInfo = commandHandlerType.GetField(privateShapeFileDirectoryName, BindingFlags.NonPublic | BindingFlags.Instance);

            if (fieldInfo == null)
            {
                Assert.Fail("Unable to find private field '{0}'", privateShapeFileDirectoryName);
            }
            else
            {
                fieldInfo.SetValue(handler, nonExistingFolder);
            }
        }
예제 #6
0
        private void OnStartup(object sender, StartupEventArgs e)
        {
            ParseArguments(e.Args);

            DeleteOldLogFiles();

            Resources.Add(SystemParameters.MenuPopupAnimationKey, PopupAnimation.None);

            var settings = new GuiCoreSettings
            {
                ApplicationName          = "Riskeer",
                ApplicationIcon          = ApplicationResources.Riskeer,
                SupportHeader            = ApplicationResources.SupportHeader,
                SupportText              = ApplicationResources.SupportText,
                SupportWebsiteAddressUrl = "https://iplo.nl/contact/",
                SupportPhoneNumber       = "088-7970790",
                ManualFilePath           = "Gebruikershandleiding Riskeer 22.1.1.pdf",
                MadeByBitmapImage        = new BitmapImage(new Uri($"{PackUriHelper.UriSchemePack}://application:,,,/Resources/MadeBy.png"))
            };

            var mainWindow      = new MainWindow();
            var projectMigrator = new ProjectMigrator(new DialogBasedInquiryHelper(mainWindow));
            var assessmentSectionFromFileHandler = new AssessmentSectionFromFileHandler(mainWindow);
            var projectFactory = new RiskeerProjectFactory(() => assessmentSectionFromFileHandler.GetAssessmentSectionFromFile());

            gui = new GuiCore(mainWindow, new StorageSqLite(), projectMigrator, projectFactory, settings)
            {
                Plugins =
                {
                    new RiskeerPlugin(),
                    new ClosingStructuresPlugin(),
                    new StabilityPointStructuresPlugin(),
                    new WaveImpactAsphaltCoverPlugin(),
                    new GrassCoverErosionInwardsPlugin(),
                    new GrassCoverErosionOutwardsPlugin(),
                    new PipingPlugin(),
                    new HeightStructuresPlugin(),
                    new StabilityStoneCoverPlugin(),
                    new DuneErosionPlugin(),
                    new MacroStabilityInwardsPlugin()
                }
            };

            RunRiskeer();
        }
        public void GetAssessmentSectionFromFile_ShapeWithoutPointsOkClicked_LogsAndReturnsAssessmentSectionWithoutReferenceLine()
        {
            // Setup
            var mockRepository = new MockRepository();
            var parentDialog   = mockRepository.Stub <IWin32Window>();

            mockRepository.ReplayAll();

            var assessmentSectionFromFileHandler = new AssessmentSectionFromFileHandler(parentDialog);

            string pathValidFolder = Path.Combine(testDataPath, "ShapeWithoutPoints");

            SetShapeFileDirectory(assessmentSectionFromFileHandler, pathValidFolder);

            DialogBoxHandler = (name, wnd) =>
            {
                var          selectionDialog = (ReferenceLineMetaSelectionDialog) new FormTester(name).TheObject;
                var          grid            = (DataGridViewControl) new ControlTester("ReferenceLineMetaDataGridViewControl", selectionDialog).TheObject;
                DataGridView dataGridView    = grid.Controls.OfType <DataGridView>().First();
                dataGridView.Rows[1].Selected = true;

                new ButtonTester("Ok", selectionDialog).Click();
            };

            AssessmentSection assessmentSection = null;

            // Call
            void Call() => assessmentSection = assessmentSectionFromFileHandler.GetAssessmentSectionFromFile();

            // Assert
            const string expectedMessage = "Het importeren van de referentielijn is mislukt.";

            TestHelper.AssertLogMessageIsGenerated(Call, expectedMessage);
            Assert.IsNotNull(assessmentSection);

            AssessmentSection expectedAssessmentSection = TestAssessmentSection1_2(true);

            expectedAssessmentSection.ReferenceLine.SetGeometry(Enumerable.Empty <Point2D>());

            AssertAssessmentSection(expectedAssessmentSection, assessmentSection);
            mockRepository.VerifyAll();
        }
        public void GetAssessmentSectionFromFile_ShapeWithInvalidNorm_ThrowsCriticalFileValidationException()
        {
            // Setup
            var mockRepository = new MockRepository();
            var parentDialog   = mockRepository.Stub <IWin32Window>();

            mockRepository.ReplayAll();

            var assessmentSectionFromFileHandler = new AssessmentSectionFromFileHandler(parentDialog);

            string pathValidFolder = Path.Combine(testDataPath, "InvalidNorm");

            SetShapeFileDirectory(assessmentSectionFromFileHandler, pathValidFolder);

            DialogBoxHandler = (name, wnd) =>
            {
                var selectionDialog = (ReferenceLineMetaSelectionDialog) new FormTester(name).TheObject;

                DataGridView dataGridView = ControlTestHelper.GetDataGridView(selectionDialog, "dataGridView");
                dataGridView.Rows[0].Selected = true;

                new ButtonTester("Ok", selectionDialog).Click();
            };

            // Call
            void Call() => assessmentSectionFromFileHandler.GetAssessmentSectionFromFile();

            // Assert
            const string expectedMessage = "Het traject kan niet aangemaakt worden met een omgevingswaarde van 1/9.999.999 en een signaleringsparameter van 1/8.888.888. " +
                                           "De waarde van de omgevingswaarde en signaleringsparameter moet in het bereik [0,000001, 0,1] liggen en " +
                                           "de omgevingswaarde moet gelijk zijn aan of groter zijn dan de signaleringsparameter.";
            var exception = Assert.Throws <CriticalFileValidationException>(Call);

            Assert.AreEqual(expectedMessage, exception.Message);
            Assert.IsInstanceOf <ArgumentOutOfRangeException>(exception.InnerException);
            mockRepository.VerifyAll();
        }
        public void GetAssessmentSectionFromFile_ThirdRowSelectedOkClicked_ReturnsThirdReadAssessmentSection()
        {
            // Setup
            var mockRepository = new MockRepository();
            var parentDialog   = mockRepository.Stub <IWin32Window>();

            mockRepository.ReplayAll();

            var assessmentSectionFromFileHandler = new AssessmentSectionFromFileHandler(parentDialog);

            string pathValidFolder = Path.Combine(testDataPath, "ValidShapeFile");

            SetShapeFileDirectory(assessmentSectionFromFileHandler, pathValidFolder);

            DialogBoxHandler = (name, wnd) =>
            {
                var          selectionDialog = (ReferenceLineMetaSelectionDialog) new FormTester(name).TheObject;
                var          grid            = (DataGridViewControl) new ControlTester("ReferenceLineMetaDataGridViewControl", selectionDialog).TheObject;
                DataGridView dataGridView    = grid.Controls.OfType <DataGridView>().First();
                dataGridView[0, 2].Selected = true;

                new ButtonTester("Ok", selectionDialog).Click();
            };

            AssessmentSection assessmentSection = null;

            // Call
            void Call() => assessmentSection = assessmentSectionFromFileHandler.GetAssessmentSectionFromFile();

            // Assert
            const string expectedMessage = "Er zijn geen instellingen gevonden voor het geselecteerde traject. Standaardinstellingen zullen gebruikt worden.";

            TestHelper.AssertLogMessageIsGenerated(Call, expectedMessage);
            Assert.IsNotNull(assessmentSection);
            AssertAssessmentSection(TestAssessmentSection3_3(), assessmentSection);
            mockRepository.VerifyAll();
        }
        public void GetAssessmentSectionFromFile_InvalidDirectory_ThrowsCriticalFileReadException()
        {
            // Setup
            var mockRepository = new MockRepository();
            var parentDialog   = mockRepository.Stub <IWin32Window>();

            mockRepository.ReplayAll();

            var assessmentSectionFromFileHandler = new AssessmentSectionFromFileHandler(parentDialog);

            string pathToNonExistingFolder = Path.Combine(testDataPath, "I do not exist");

            SetShapeFileDirectory(assessmentSectionFromFileHandler, pathToNonExistingFolder);

            // Call
            void Call() => assessmentSectionFromFileHandler.GetAssessmentSectionFromFile();

            // Assert
            var expectedMessage = $"De map met specificaties voor trajecten '{pathToNonExistingFolder}' is niet gevonden.";
            var exception       = Assert.Throws <CriticalFileReadException>(Call);

            Assert.AreEqual(expectedMessage, exception.Message);
            mockRepository.VerifyAll();
        }