Ejemplo n.º 1
0
        public void GetMergeData_WithAssessmentSection_SetsDataOnDialog()
        {
            // Setup
            DialogBoxHandler = (formName, wnd) =>
            {
                using (new FormTester(formName)) {}
            };

            AssessmentSection assessmentSection = TestDataGenerator.GetAssessmentSectionWithAllCalculationConfigurationsAndSpecificFailureMechanisms();

            using (var dialogParent = new Form())
                using (var dialog = new AssessmentSectionMergeDataProviderDialog(dialogParent))
                {
                    // Call
                    dialog.GetMergeData(assessmentSection);

                    // Assert
                    var dataGridView = (DataGridView) new ControlTester("dataGridView", dialog).TheObject;
                    DataGridViewRowCollection rows = dataGridView.Rows;

                    int expectedNrOfRows = assessmentSection.GetFailureMechanisms().Count() +
                                           assessmentSection.SpecificFailureMechanisms.Count;
                    Assert.AreEqual(expectedNrOfRows, rows.Count);
                    AssertFailureMechanismRows(assessmentSection, rows);
                    AssertSpecificFailureMechanismRows(assessmentSection, rows);
                }
        }
Ejemplo n.º 2
0
        public void GivenValidDialog_WhenGetMergeDataCalledAndAllDataSelectedAndImportPressed_ThenReturnsSelectedData()
        {
            // Given
            AssessmentSection assessmentSection = TestDataGenerator.GetAssessmentSectionWithAllCalculationConfigurationsAndSpecificFailureMechanisms();

            DialogBoxHandler = (formName, wnd) =>
            {
                using (var formTester = new FormTester(formName))
                {
                    var dialog = (AssessmentSectionMergeDataProviderDialog)formTester.TheObject;

                    var dataGridView = (DataGridView) new ControlTester("dataGridView", dialog).TheObject;

                    DataGridViewRowCollection rows = dataGridView.Rows;

                    foreach (DataGridViewRow row in rows)
                    {
                        row.Cells[isSelectedIndex].Value = true;
                    }

                    var button = new ButtonTester("importButton", formName);
                    button.Click();
                }
            };

            using (var dialogParent = new Form())
                using (var dialog = new AssessmentSectionMergeDataProviderDialog(dialogParent))
                {
                    // When
                    AssessmentSectionMergeData result = dialog.GetMergeData(assessmentSection);

                    // Then
                    Assert.AreSame(assessmentSection, result.AssessmentSection);

                    Assert.IsTrue(result.MergePiping);
                    Assert.IsTrue(result.MergeGrassCoverErosionInwards);
                    Assert.IsTrue(result.MergeMacroStabilityInwards);
                    Assert.IsTrue(result.MergeMicrostability);
                    Assert.IsTrue(result.MergeStabilityStoneCover);
                    Assert.IsTrue(result.MergeWaveImpactAsphaltCover);
                    Assert.IsTrue(result.MergeWaterPressureAsphaltCover);
                    Assert.IsTrue(result.MergeGrassCoverErosionOutwards);
                    Assert.IsTrue(result.MergeGrassCoverSlipOffOutwards);
                    Assert.IsTrue(result.MergeGrassCoverSlipOffInwards);
                    Assert.IsTrue(result.MergeHeightStructures);
                    Assert.IsTrue(result.MergeClosingStructures);
                    Assert.IsTrue(result.MergePipingStructure);
                    Assert.IsTrue(result.MergeStabilityPointStructures);
                    Assert.IsTrue(result.MergeDuneErosion);
                    CollectionAssert.AreEqual(assessmentSection.SpecificFailureMechanisms, result.MergeSpecificFailureMechanisms);
                }
        }
Ejemplo n.º 3
0
        public void GetMergeData_AssessmentSectionNull_ThrowsArgumentNullException()
        {
            // Setup
            var mocks        = new MockRepository();
            var dialogParent = mocks.Stub <IWin32Window>();

            mocks.ReplayAll();

            using (var dialog = new AssessmentSectionMergeDataProviderDialog(dialogParent))
            {
                // Call
                void Call() => dialog.GetMergeData(null);

                // Assert
                var exception = Assert.Throws <ArgumentNullException>(Call);
                Assert.AreEqual("assessmentSection", exception.ParamName);
            }

            mocks.VerifyAll();
        }
Ejemplo n.º 4
0
        public void GivenValidDialog_WhenGetMergeDataCalledAndImportPressed_ThenReturnsSelectedData()
        {
            // Given
            AssessmentSection assessmentSection = TestDataGenerator.GetAssessmentSectionWithAllCalculationConfigurationsAndSpecificFailureMechanisms();

            DialogBoxHandler = (formName, wnd) =>
            {
                using (new FormTester(formName))
                {
                    var button = new ButtonTester("importButton", formName);
                    button.Click();
                }
            };

            using (var dialogParent = new Form())
                using (var dialog = new AssessmentSectionMergeDataProviderDialog(dialogParent))
                {
                    // When
                    AssessmentSectionMergeData result = dialog.GetMergeData(assessmentSection);

                    // Then
                    Assert.AreSame(assessmentSection, result.AssessmentSection);

                    Assert.IsFalse(result.MergePiping);
                    Assert.IsFalse(result.MergeGrassCoverErosionInwards);
                    Assert.IsFalse(result.MergeMacroStabilityInwards);
                    Assert.IsFalse(result.MergeMicrostability);
                    Assert.IsFalse(result.MergeStabilityStoneCover);
                    Assert.IsFalse(result.MergeWaveImpactAsphaltCover);
                    Assert.IsFalse(result.MergeWaterPressureAsphaltCover);
                    Assert.IsFalse(result.MergeGrassCoverErosionOutwards);
                    Assert.IsFalse(result.MergeGrassCoverSlipOffOutwards);
                    Assert.IsFalse(result.MergeGrassCoverSlipOffInwards);
                    Assert.IsFalse(result.MergeHeightStructures);
                    Assert.IsFalse(result.MergeClosingStructures);
                    Assert.IsFalse(result.MergePipingStructure);
                    Assert.IsFalse(result.MergeStabilityPointStructures);
                    Assert.IsFalse(result.MergeDuneErosion);
                    CollectionAssert.IsEmpty(result.MergeSpecificFailureMechanisms);
                }
        }
Ejemplo n.º 5
0
        public void GivenValidDialog_WhenGetMergeDataCalledAndCancelPressed_ThenReturnsNull()
        {
            // Given
            DialogBoxHandler = (formName, wnd) =>
            {
                using (new FormTester(formName))
                {
                    var button = new ButtonTester("cancelButton", formName);
                    button.Click();
                }
            };

            using (var dialogParent = new Form())
                using (var dialog = new AssessmentSectionMergeDataProviderDialog(dialogParent))
                {
                    // When
                    AssessmentSectionMergeData result = dialog.GetMergeData(TestDataGenerator.GetAssessmentSectionWithAllCalculationConfigurationsAndSpecificFailureMechanisms());

                    // Then
                    Assert.IsNull(result);
                }
        }