예제 #1
0
        public void Constructor_ExpectedValues()
        {
            // Setup
            var mocks   = new MockRepository();
            var handler = mocks.Stub <IObservablePropertyChangeHandler>();

            mocks.ReplayAll();

            var calculationScenario = new StructuresCalculationScenario <HeightStructuresInput>();

            // Call
            var row = new HeightStructuresCalculationRow(calculationScenario, handler);

            // Assert
            Assert.IsInstanceOf <CalculationRow <StructuresCalculationScenario <HeightStructuresInput> > >(row);
            Assert.IsInstanceOf <IHasColumnStateDefinitions>(row);

            Assert.AreSame(calculationScenario, row.Calculation);

            IDictionary <int, DataGridViewColumnStateDefinition> columnStateDefinitions = row.ColumnStateDefinitions;

            Assert.AreEqual(4, columnStateDefinitions.Count);

            DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnStateDefinition(columnStateDefinitions, useBreakWaterColumnIndex);
            DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnStateDefinition(columnStateDefinitions, breakWaterTypeColumnIndex);
            DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnStateDefinition(columnStateDefinitions, breakWaterHeightColumnIndex);
            DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnStateDefinition(columnStateDefinitions, useForeshoreColumnIndex);
            mocks.VerifyAll();
        }
예제 #2
0
        public void ForeshoreProfile_OnChangeToNull_CorrectColumnStates()
        {
            // Setup
            var calculation = new StructuresCalculationScenario <HeightStructuresInput>
            {
                InputParameters =
                {
                    ForeshoreProfile = new TestForeshoreProfile()
                }
            };

            // Call
            var row = new HeightStructuresCalculationRow(calculation, new ObservablePropertyChangeHandler(calculation, new HeightStructuresInput()))
            {
                ForeshoreProfile = new DataGridViewComboBoxItemWrapper <ForeshoreProfile>(null)
            };

            // Assert
            IDictionary <int, DataGridViewColumnStateDefinition> columnStateDefinitions = row.ColumnStateDefinitions;

            DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnState(columnStateDefinitions[useBreakWaterColumnIndex], false);
            DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnState(columnStateDefinitions[breakWaterTypeColumnIndex], false);
            DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnState(columnStateDefinitions[breakWaterHeightColumnIndex], false);
            DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnState(columnStateDefinitions[useForeshoreColumnIndex], false);
        }
예제 #3
0
        public void Constructor_ForeshoreProfileWithGeometry_CorrectColumnStates(bool useBreakWater)
        {
            // Setup
            var calculation = new StructuresCalculationScenario <HeightStructuresInput>
            {
                InputParameters =
                {
                    ForeshoreProfile = new TestForeshoreProfile(new[]
                    {
                        new Point2D(0.0, 0.0)
                    }),
                    UseBreakWater    = useBreakWater
                }
            };

            // Call
            var row = new HeightStructuresCalculationRow(calculation, new ObservablePropertyChangeHandler(calculation, new HeightStructuresInput()));

            // Assert
            IDictionary <int, DataGridViewColumnStateDefinition> columnStateDefinitions = row.ColumnStateDefinitions;

            DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnState(columnStateDefinitions[useBreakWaterColumnIndex], true);
            DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnState(columnStateDefinitions[breakWaterTypeColumnIndex], useBreakWater);
            DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnState(columnStateDefinitions[breakWaterHeightColumnIndex], useBreakWater);
            DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnState(columnStateDefinitions[useForeshoreColumnIndex], true);
        }
예제 #4
0
        private static void AssertPropertyChangeWithOrWithoutCalculationOutput(
            Action <HeightStructuresCalculationRow> setProperty,
            Action <StructuresCalculationScenario <HeightStructuresInput> > assertions,
            bool hasOutput,
            bool expectUpdates)
        {
            // Setup
            var mockRepository = new MockRepository();
            var inputObserver  = mockRepository.StrictMock <IObserver>();

            if (expectUpdates)
            {
                inputObserver.Expect(o => o.UpdateObserver());
            }

            var calculationObserver = mockRepository.StrictMock <IObserver>();

            if (expectUpdates && hasOutput)
            {
                calculationObserver.Expect(o => o.UpdateObserver());
            }

            var handler = mockRepository.Stub <IObservablePropertyChangeHandler>();

            mockRepository.ReplayAll();

            StructuresOutput assignedOutput = null;

            StructuresCalculationScenario <HeightStructuresInput> calculation = HeightStructuresCalculationScenarioTestFactory.CreateNotCalculatedHeightStructuresCalculationScenario(new FailureMechanismSection("Section 1", new List <Point2D>
            {
                new Point2D(0.0, 0.0)
            }));

            calculation.InputParameters.HydraulicBoundaryLocation = new TestHydraulicBoundaryLocation();
            if (hasOutput)
            {
                assignedOutput = new TestStructuresOutput();
            }

            calculation.Output = assignedOutput;

            var row = new HeightStructuresCalculationRow(calculation, handler);

            calculation.Attach(calculationObserver);
            calculation.InputParameters.Attach(inputObserver);

            // Call
            setProperty(row);

            // Assert
            assertions(calculation);
            if (expectUpdates)
            {
                Assert.IsNull(calculation.Output);
            }
            else
            {
                Assert.AreSame(assignedOutput, calculation.Output);
            }
        }
예제 #5
0
        private static void SetPropertyAndVerifyNotificationsAndOutputForCalculation(
            Action <HeightStructuresCalculationRow> setProperty,
            StructuresCalculationScenario <HeightStructuresInput> calculation)
        {
            // Setup
            var mocks      = new MockRepository();
            var observable = mocks.StrictMock <IObservable>();

            observable.Expect(o => o.NotifyObservers());
            mocks.ReplayAll();

            var handler = new SetPropertyValueAfterConfirmationParameterTester(
                new[]
            {
                observable
            });

            var row = new HeightStructuresCalculationRow(calculation, handler);

            // Call
            setProperty(row);

            // Assert
            Assert.IsTrue(handler.Called);
            mocks.VerifyAll();
        }
예제 #6
0
        public void Constructor_ForeshoreProfileNull_CorrectColumnStates()
        {
            // Setup
            var calculation = new StructuresCalculationScenario <HeightStructuresInput>();

            // Call
            var row = new HeightStructuresCalculationRow(calculation, new ObservablePropertyChangeHandler(calculation, new HeightStructuresInput()));

            // Assert
            IDictionary <int, DataGridViewColumnStateDefinition> columnStateDefinitions = row.ColumnStateDefinitions;

            DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnState(columnStateDefinitions[useBreakWaterColumnIndex], false);
            DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnState(columnStateDefinitions[breakWaterTypeColumnIndex], false);
            DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnState(columnStateDefinitions[breakWaterHeightColumnIndex], false);
            DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnState(columnStateDefinitions[useForeshoreColumnIndex], false);
        }
예제 #7
0
        public void UseBreakWater_AlwaysOnChange_CorrectColumnStates(bool useBreakWater)
        {
            // Setup
            var calculation = new StructuresCalculationScenario <HeightStructuresInput>
            {
                InputParameters =
                {
                    ForeshoreProfile = new TestForeshoreProfile()
                }
            };

            // Call
            var row = new HeightStructuresCalculationRow(calculation, new ObservablePropertyChangeHandler(calculation, new HeightStructuresInput()))
            {
                UseBreakWater = useBreakWater
            };

            // Assert
            IDictionary <int, DataGridViewColumnStateDefinition> columnStateDefinitions = row.ColumnStateDefinitions;

            DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnState(columnStateDefinitions[breakWaterTypeColumnIndex], useBreakWater);
            DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnState(columnStateDefinitions[breakWaterHeightColumnIndex], useBreakWater);
        }