public void CreateInstance_StabilityStoneCoverWaveConditionsInputContext_ReturnViewWithStylingApplied()
        {
            // Setup
            var calculation = new StabilityStoneCoverWaveConditionsCalculation();
            var context     = new StabilityStoneCoverWaveConditionsInputContext(
                new StabilityStoneCoverWaveConditionsInput(),
                calculation,
                new AssessmentSectionStub(),
                Array.Empty <ForeshoreProfile>());

            // Call
            var view = (WaveConditionsInputView)info.CreateInstance(context);

            // Assert
            ChartDataCollection chartData = view.Chart.Data;

            var lowerBoundaryRevetmentChartData = (ChartLineData)chartData.Collection.ElementAt(lowerBoundaryRevetmentChartDataIndex);
            var upperBoundaryRevetmentChartData = (ChartLineData)chartData.Collection.ElementAt(upperBoundaryRevetmentChartDataIndex);
            var revetmentBaseChartData          = (ChartLineData)chartData.Collection.ElementAt(revetmentBaseChartDataIndex);
            var revetmentChartData = (ChartLineData)chartData.Collection.ElementAt(revetmentChartDataIndex);

            Color revetmentLineColor = Color.Gray;

            Assert.AreEqual(revetmentLineColor, lowerBoundaryRevetmentChartData.Style.Color);
            Assert.AreEqual(revetmentLineColor, upperBoundaryRevetmentChartData.Style.Color);
            Assert.AreEqual(Color.FromArgb(120, revetmentLineColor), revetmentBaseChartData.Style.Color);
            Assert.AreEqual(revetmentLineColor, revetmentChartData.Style.Color);
        }
        public void CreateInstance_WithContextThatHasInputWithSpecificWaterLevelType_ReturnViewWithCorrespondingAssessmentLevel(
            IAssessmentSection assessmentSection,
            Action <WaveConditionsInput> configureInputAction,
            RoundedDouble expectedAssessmentLevel)
        {
            // Setup
            var calculation = new StabilityStoneCoverWaveConditionsCalculation();

            configureInputAction(calculation.InputParameters);

            var context = new StabilityStoneCoverWaveConditionsInputContext(
                calculation.InputParameters,
                calculation,
                assessmentSection,
                Array.Empty <ForeshoreProfile>());

            // Call
            var view = (WaveConditionsInputView)info.CreateInstance(context);

            // Assert
            ChartDataCollection chartData = view.Chart.Data;
            var designWaterLevelChartData = (ChartLineData)chartData.Collection.ElementAt(designWaterLevelChartDataIndex);

            if (expectedAssessmentLevel != RoundedDouble.NaN)
            {
                Assert.AreEqual(expectedAssessmentLevel, designWaterLevelChartData.Points.First().Y);
            }
            else
            {
                Assert.IsEmpty(designWaterLevelChartData.Points);
            }
        }
コード例 #3
0
        public void Constructor_Always_PropertiesHaveExpectedAttributesValues()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();
            var handler           = mocks.Stub <IObservablePropertyChangeHandler>();

            mocks.ReplayAll();

            var calculation = new StabilityStoneCoverWaveConditionsCalculation();
            var context     = new StabilityStoneCoverWaveConditionsInputContext(
                calculation.InputParameters,
                calculation,
                assessmentSection,
                Enumerable.Empty <ForeshoreProfile>());

            // Call
            var properties = new StabilityStoneCoverWaveConditionsInputContextProperties(
                context, AssessmentSectionTestHelper.GetTestAssessmentLevel, handler);

            // Assert
            PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties);

            Assert.AreEqual(16, dynamicProperties.Count);

            PropertyDescriptor revetmentTypeProperty = dynamicProperties[10];

            Assert.IsInstanceOf <EnumTypeConverter>(revetmentTypeProperty.Converter);
            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(revetmentTypeProperty,
                                                                            "Modelinstellingen",
                                                                            "Type bekleding",
                                                                            "Het type van de bekleding waarvoor berekend wordt.");
            mocks.VerifyAll();
        }
コード例 #4
0
        public void Constructor_ExpectedValues()
        {
            // Setup
            var mockRepository    = new MockRepository();
            var assessmentSection = mockRepository.Stub <IAssessmentSection>();
            var handler           = mockRepository.Stub <IObservablePropertyChangeHandler>();

            mockRepository.ReplayAll();

            var calculation = new StabilityStoneCoverWaveConditionsCalculation();
            var context     = new StabilityStoneCoverWaveConditionsInputContext(
                calculation.InputParameters,
                calculation,
                assessmentSection,
                Enumerable.Empty <ForeshoreProfile>());

            // Call
            var properties = new StabilityStoneCoverWaveConditionsInputContextProperties(context, () => (RoundedDouble)1.1, handler);

            // Assert
            Assert.IsInstanceOf <WaveConditionsInputContextProperties <
                                     StabilityStoneCoverWaveConditionsInputContext, StabilityStoneCoverWaveConditionsInput,
                                     StabilityStoneCoverWaveConditionsCalculationType> >(properties);
            Assert.AreSame(context, properties.Data);
            Assert.AreEqual(calculation.InputParameters.CalculationType, properties.RevetmentType);
            mockRepository.VerifyAll();
        }
コード例 #5
0
        public void RevetmentType_Always_InputChangedAndObservablesNotified()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();
            var observable        = mocks.StrictMock <IObservable>();

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

            var calculation = new StabilityStoneCoverWaveConditionsCalculation();
            var context     = new StabilityStoneCoverWaveConditionsInputContext(
                calculation.InputParameters,
                calculation,
                assessmentSection,
                Enumerable.Empty <ForeshoreProfile>());

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

            var properties = new StabilityStoneCoverWaveConditionsInputContextProperties(
                context, AssessmentSectionTestHelper.GetTestAssessmentLevel, customHandler);

            var calculationType = new Random(21).NextEnumValue <StabilityStoneCoverWaveConditionsCalculationType>();

            // Call
            properties.RevetmentType = calculationType;

            // Assert
            Assert.IsTrue(customHandler.Called);
            mocks.VerifyAll();
        }
コード例 #6
0
        public void CreateInstance_WithContextThatHasInputWithSpecificWaterLevelType_ExpectedProperties(
            IAssessmentSection assessmentSection,
            Action <WaveConditionsInput> configureInputAction,
            RoundedDouble expectedAssessmentLevel)
        {
            // Setup
            var calculation = new StabilityStoneCoverWaveConditionsCalculation();

            configureInputAction(calculation.InputParameters);

            var context = new StabilityStoneCoverWaveConditionsInputContext(calculation.InputParameters,
                                                                            calculation,
                                                                            assessmentSection,
                                                                            Array.Empty <ForeshoreProfile>());

            using (var plugin = new StabilityStoneCoverPlugin())
            {
                PropertyInfo info = GetInfo(plugin);

                // Call
                IObjectProperties objectProperties = info.CreateInstance(context);

                // Assert
                Assert.IsInstanceOf <StabilityStoneCoverWaveConditionsInputContextProperties>(objectProperties);
                Assert.AreSame(context, objectProperties.Data);

                Assert.AreEqual(expectedAssessmentLevel, ((StabilityStoneCoverWaveConditionsInputContextProperties)objectProperties).AssessmentLevel);
            }
        }
コード例 #7
0
        public void Constructor_ExpectedValues()
        {
            // Setup
            var calculation       = new StabilityStoneCoverWaveConditionsCalculation();
            var foreshoreProfiles = new[]
            {
                new TestForeshoreProfile()
            };

            var assessmentSection = new AssessmentSectionStub();

            // Call
            var context = new StabilityStoneCoverWaveConditionsInputContext(calculation.InputParameters,
                                                                            calculation,
                                                                            assessmentSection,
                                                                            foreshoreProfiles);

            // Assert
            Assert.IsInstanceOf <WaveConditionsInputContext <StabilityStoneCoverWaveConditionsInput> >(context);
            Assert.AreSame(calculation.InputParameters, context.WrappedData);
            Assert.AreSame(calculation, context.Calculation);
            Assert.AreSame(assessmentSection, context.AssessmentSection);
            Assert.AreSame(foreshoreProfiles, context.ForeshoreProfiles);
        }