Beispiel #1
0
        public void GivenGrassCoverErosionInwardsFailureMechanismResultView_WhenApplyLengthEffectChangedAndFailureMechanismObserversNotified_ThenDataGridViewUpdated(
            bool useLengthEffect)
        {
            var failureMechanism = new GrassCoverErosionInwardsFailureMechanism
            {
                GeneralInput =
                {
                    ApplyLengthEffectInSection = !useLengthEffect
                }
            };
            FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection("Section 1");

            FailureMechanismTestHelper.SetSections(failureMechanism, new[]
            {
                section
            });

            GrassCoverErosionInwardsCalculationScenario calculationScenario = GrassCoverErosionInwardsCalculationScenarioTestFactory.CreateGrassCoverErosionInwardsCalculationScenario(section);

            failureMechanism.CalculationsGroup.Children.Add(calculationScenario);

            using (new AssemblyToolCalculatorFactoryConfig())
                using (ShowFailureMechanismResultsView(failureMechanism))
                {
                    var          rowsChanged  = false;
                    DataGridView dataGridView = GetDataGridView();
                    dataGridView.Rows.CollectionChanged += (sender, args) => rowsChanged = true;

                    // Precondition
                    Assert.IsFalse(rowsChanged);
                    Assert.AreEqual(!useLengthEffect, dataGridView.Columns[initialFailureMechanismResultProfileProbabilityIndex].Visible);
                    Assert.AreEqual(!useLengthEffect, dataGridView.Columns[probabilityRefinementTypeIndex].Visible);
                    Assert.AreEqual(!useLengthEffect, dataGridView.Columns[refinedProfileProbabilityIndex].Visible);
                    Assert.AreEqual(!useLengthEffect, dataGridView.Columns[profileProbabilityIndex].Visible);
                    Assert.AreEqual(!useLengthEffect, dataGridView.Columns[sectionNIndex].Visible);

                    // When
                    failureMechanism.GeneralInput.ApplyLengthEffectInSection = useLengthEffect;
                    failureMechanism.NotifyObservers();

                    // Then
                    Assert.IsTrue(rowsChanged);
                    Assert.AreEqual(useLengthEffect, dataGridView.Columns[initialFailureMechanismResultProfileProbabilityIndex].Visible);
                    Assert.AreEqual(useLengthEffect, dataGridView.Columns[probabilityRefinementTypeIndex].Visible);
                    Assert.AreEqual(useLengthEffect, dataGridView.Columns[refinedProfileProbabilityIndex].Visible);
                    Assert.AreEqual(useLengthEffect, dataGridView.Columns[profileProbabilityIndex].Visible);
                    Assert.AreEqual(useLengthEffect, dataGridView.Columns[sectionNIndex].Visible);
                }
        }
Beispiel #2
0
        public void GivenViewWithFailureMechanismSectionsData_WhenFailureMechanismUpdatedAndNotified_ThenMapDataUpdated()
        {
            // Given
            var failureMechanism = new GrassCoverErosionInwardsFailureMechanism();

            GrassCoverErosionInwardsFailureMechanismView view = CreateView(failureMechanism, new AssessmentSectionStub());

            IMapControl map = ((RiskeerMapControl)view.Controls[0]).MapControl;

            IEnumerable <MapData> sectionsCollection = ((MapDataCollection)map.Data.Collection.ElementAt(sectionsCollectionIndex)).Collection;
            var sectionMapData       = (MapLineData)sectionsCollection.ElementAt(sectionsIndex);
            var sectionStartsMapData = (MapPointData)sectionsCollection.ElementAt(sectionsStartPointIndex);
            var sectionsEndsMapData  = (MapPointData)sectionsCollection.ElementAt(sectionsEndPointIndex);

            var mocks = new MockRepository();

            IObserver[] observers = AttachMapDataObservers(mocks, map.Data.Collection);
            observers[sectionsObserverIndex].Expect(obs => obs.UpdateObserver());
            observers[sectionsStartPointObserverIndex].Expect(obs => obs.UpdateObserver());
            observers[sectionsEndPointObserverIndex].Expect(obs => obs.UpdateObserver());
            mocks.ReplayAll();

            // When
            FailureMechanismTestHelper.SetSections(failureMechanism, new[]
            {
                new FailureMechanismSection(string.Empty, new[]
                {
                    new Point2D(1, 2),
                    new Point2D(1, 2)
                })
            });
            failureMechanism.NotifyObservers();

            // Then
            MapDataTestHelper.AssertFailureMechanismSectionsMapData(failureMechanism.Sections, sectionMapData);
            MapDataTestHelper.AssertFailureMechanismSectionsStartPointMapData(failureMechanism.Sections, sectionStartsMapData);
            MapDataTestHelper.AssertFailureMechanismSectionsEndPointMapData(failureMechanism.Sections, sectionsEndsMapData);
            mocks.VerifyAll();
        }