public void ContextMenuStrip_Always_CallsContextMenuBuilderMethods()
        {
            // Setup
            var mocks = new MockRepository();

            using (var treeViewControl = new TreeViewControl())
            {
                GrassCoverErosionOutwardsWaveConditionsOutput output = GrassCoverErosionOutwardsWaveConditionsOutputTestFactory.Create();
                var context = new GrassCoverErosionOutwardsWaveConditionsOutputContext(output, new GrassCoverErosionOutwardsWaveConditionsInput());

                var menuBuilder = mocks.StrictMock <IContextMenuBuilder>();
                using (mocks.Ordered())
                {
                    menuBuilder.Expect(mb => mb.AddPropertiesItem()).Return(menuBuilder);
                    menuBuilder.Expect(mb => mb.Build()).Return(null);
                }

                var gui = mocks.Stub <IGui>();
                gui.Stub(cmp => cmp.Get(context, treeViewControl)).Return(menuBuilder);
                mocks.ReplayAll();

                using (var plugin = new GrassCoverErosionOutwardsPlugin())
                {
                    TreeNodeInfo info = GetInfo(plugin);
                    plugin.Gui = gui;

                    // Call
                    info.ContextMenuStrip(context, null, treeViewControl);
                }
            }

            // Assert
            mocks.VerifyAll();
        }
示例#2
0
        public void Constructor_CalculationTypeWaveRunUpOrWaveImpact_PropertiesHaveExpectedAttributesValues(
            GrassCoverErosionOutwardsWaveConditionsCalculationType calculationType, string expectedDisplayName, string expectedDescription)
        {
            // Setup
            GrassCoverErosionOutwardsWaveConditionsOutput output = GrassCoverErosionOutwardsWaveConditionsOutputTestFactory.Create();
            var input = new GrassCoverErosionOutwardsWaveConditionsInput
            {
                CalculationType = calculationType
            };

            // Call
            var properties = new GrassCoverErosionOutwardsWaveConditionsOutputProperties(output, input);

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

            Assert.AreEqual(1, dynamicProperties.Count);

            PropertyDescriptor outputProperty = dynamicProperties[0];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(outputProperty,
                                                                            "Resultaat",
                                                                            expectedDisplayName,
                                                                            expectedDescription,
                                                                            true);
        }
示例#3
0
        public void Clone_OutputNull_ReturnsNewInstanceWithCopiedValues()
        {
            // Setup
            var original = new GrassCoverErosionOutwardsWaveConditionsOutput(null, null, null);

            // Call
            object clone = original.Clone();

            // Assert
            CoreCloneAssert.AreObjectClones(original, clone, GrassCoverErosionOutwardsCloneAssert.AreClones);
        }
示例#4
0
        public void Constructor_ExpectedValues()
        {
            // Setup
            GrassCoverErosionOutwardsWaveConditionsOutput output =
                GrassCoverErosionOutwardsWaveConditionsOutputTestFactory.Create();

            // Call
            var properties = new GrassCoverErosionOutwardsWaveConditionsOutputProperties(output, new GrassCoverErosionOutwardsWaveConditionsInput());

            // Assert
            Assert.IsInstanceOf <ObjectProperties <GrassCoverErosionOutwardsWaveConditionsOutput> >(properties);
            Assert.AreSame(output, properties.Data);
        }
示例#5
0
        public void Constructor_InputNull_ThrowsArgumentNullException()
        {
            // Setup
            GrassCoverErosionOutwardsWaveConditionsOutput output = GrassCoverErosionOutwardsWaveConditionsOutputTestFactory.Create();

            // Call
            TestDelegate call = () => new GrassCoverErosionOutwardsWaveConditionsOutputProperties(output, null);

            // Assert
            var exception = Assert.Throws <ArgumentNullException>(call);

            Assert.AreEqual("input", exception.ParamName);
        }
示例#6
0
        public void Constructor_WithArguments_ExpectedValues()
        {
            // Setup
            GrassCoverErosionOutwardsWaveConditionsOutput output = GrassCoverErosionOutwardsWaveConditionsOutputTestFactory.Create();
            var input = new GrassCoverErosionOutwardsWaveConditionsInput();

            // Call
            var context = new GrassCoverErosionOutwardsWaveConditionsOutputContext(output, input);

            // Assert
            Assert.IsInstanceOf <ObservableWrappedObjectContextBase <GrassCoverErosionOutwardsWaveConditionsOutput> >(context);
            Assert.AreSame(input, context.Input);
            Assert.AreSame(output, context.WrappedData);
        }
        public void CreateOutputWithWaveImpact_WithWaveImpactOutput_ReturnsOutput()
        {
            // Setup
            IEnumerable <WaveConditionsOutput> waveImpactOutput = Enumerable.Empty <WaveConditionsOutput>();

            // Call
            GrassCoverErosionOutwardsWaveConditionsOutput output =
                GrassCoverErosionOutwardsWaveConditionsOutputFactory.CreateOutputWithWaveImpact(waveImpactOutput);

            // Assert
            Assert.AreSame(waveImpactOutput, output.WaveImpactOutput);
            Assert.IsNull(output.WaveRunUpOutput);
            Assert.IsNull(output.WaveImpactWithWaveDirectionOutput);
        }
示例#8
0
        public void Constructor_ExpectedValues()
        {
            // Setup
            IEnumerable <WaveConditionsOutput> waveRunUpOutput  = Enumerable.Empty <WaveConditionsOutput>();
            IEnumerable <WaveConditionsOutput> waveImpactOutput = Enumerable.Empty <WaveConditionsOutput>();
            IEnumerable <WaveConditionsOutput> waveImpactWithWaveDirectionOutput = Enumerable.Empty <WaveConditionsOutput>();

            // Call
            var output = new GrassCoverErosionOutwardsWaveConditionsOutput(waveRunUpOutput, waveImpactOutput, waveImpactWithWaveDirectionOutput);

            // Assert
            Assert.IsInstanceOf <CloneableObservable>(output);
            Assert.IsInstanceOf <ICalculationOutput>(output);
            Assert.AreSame(waveRunUpOutput, output.WaveRunUpOutput);
            Assert.AreSame(waveImpactOutput, output.WaveImpactOutput);
            Assert.AreSame(waveImpactWithWaveDirectionOutput, output.WaveImpactWithWaveDirectionOutput);
        }
示例#9
0
        public void DynamicVisibleValidationMethod_DependingOnRelevancy_ReturnExpectedVisibility(
            GrassCoverErosionOutwardsWaveConditionsCalculationType calculationType, bool waveRunUpVisible, bool waveImpactVisible, bool waveImpactWithWaveDirectionVisible)
        {
            // Setup
            GrassCoverErosionOutwardsWaveConditionsOutput output = GrassCoverErosionOutwardsWaveConditionsOutputTestFactory.Create();
            var input = new GrassCoverErosionOutwardsWaveConditionsInput
            {
                CalculationType = calculationType
            };

            var properties = new GrassCoverErosionOutwardsWaveConditionsOutputProperties(output, input);

            // Call & Assert
            Assert.AreEqual(waveRunUpVisible, properties.DynamicVisibleValidationMethod(nameof(properties.WaveRunUpOutput)));
            Assert.AreEqual(waveImpactVisible, properties.DynamicVisibleValidationMethod(nameof(properties.WaveImpactOutput)));
            Assert.AreEqual(waveImpactWithWaveDirectionVisible, properties.DynamicVisibleValidationMethod(nameof(properties.WaveImpactWithWaveDirectionOutput)));
            Assert.IsFalse(properties.DynamicVisibleValidationMethod(null));
        }
        public void CreateInstance_WithContext_SetsOutputAsData()
        {
            // Setup
            GrassCoverErosionOutwardsWaveConditionsOutput output = GrassCoverErosionOutwardsWaveConditionsOutputTestFactory.Create();
            var context = new GrassCoverErosionOutwardsWaveConditionsOutputContext(output, new GrassCoverErosionOutwardsWaveConditionsInput());

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

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

                // Assert
                Assert.IsInstanceOf <GrassCoverErosionOutwardsWaveConditionsOutputProperties>(objectProperties);
                Assert.AreSame(output, objectProperties.Data);
            }
        }
示例#11
0
        public void Constructor_CalculationTypeAll_PropertiesHaveExpectedAttributesValues()
        {
            // Setup
            GrassCoverErosionOutwardsWaveConditionsOutput output = GrassCoverErosionOutwardsWaveConditionsOutputTestFactory.Create();
            var input = new GrassCoverErosionOutwardsWaveConditionsInput
            {
                CalculationType = GrassCoverErosionOutwardsWaveConditionsCalculationType.All
            };

            // Precondition
            Assert.AreEqual(GrassCoverErosionOutwardsWaveConditionsCalculationType.All, input.CalculationType);

            // Call
            var properties = new GrassCoverErosionOutwardsWaveConditionsOutputProperties(output, input);

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

            Assert.AreEqual(3, dynamicProperties.Count);

            PropertyDescriptor waveRunUpProperty = dynamicProperties[waveRunUpPropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(waveRunUpProperty,
                                                                            "Resultaat",
                                                                            "Hydraulische belastingen voor golfoploop",
                                                                            "Berekende hydraulische belastingen voor golfoploop.",
                                                                            true);

            PropertyDescriptor waveImpactProperty = dynamicProperties[waveImpactPropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(waveImpactProperty,
                                                                            "Resultaat",
                                                                            "Hydraulische belastingen voor golfklap",
                                                                            "Berekende hydraulische belastingen voor golfklap zonder invloed van de golfinvalshoek.",
                                                                            true);

            PropertyDescriptor waveImpactWithWaveDirectionProperty = dynamicProperties[waveImpactWithWaveDirectionPropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(waveImpactWithWaveDirectionProperty,
                                                                            "Resultaat",
                                                                            "Hydraulische belastingen voor golfklap met golfrichting",
                                                                            "Berekende hydraulische belastingen voor golfklap met invloed van de golfinvalshoek.",
                                                                            true);
        }
示例#12
0
        public void Data_WithCalculationOutput_ReturnsExpectedValues()
        {
            // Setup
            var waveRunUpOutput = new[]
            {
                new TestWaveConditionsOutput()
            };

            var waveImpactOutput = new[]
            {
                new TestWaveConditionsOutput()
            };

            var waveImpactWithWaveDirectionOutput = new[]
            {
                new TestWaveConditionsOutput()
            };

            GrassCoverErosionOutwardsWaveConditionsOutput output =
                GrassCoverErosionOutwardsWaveConditionsOutputTestFactory.Create(waveRunUpOutput, waveImpactOutput, waveImpactWithWaveDirectionOutput);

            // Call
            var properties = new GrassCoverErosionOutwardsWaveConditionsOutputProperties(output, new GrassCoverErosionOutwardsWaveConditionsInput());

            // Assert
            CollectionAssert.AllItemsAreInstancesOfType(properties.WaveRunUpOutput, typeof(WaveConditionsOutputProperties));
            Assert.AreEqual(waveRunUpOutput.Length, properties.WaveRunUpOutput.Length);
            WaveConditionsOutputProperties waveRunUpProperty = properties.WaveRunUpOutput[0];

            Assert.AreSame(waveRunUpOutput[0], waveRunUpProperty.Data);

            CollectionAssert.AllItemsAreInstancesOfType(properties.WaveImpactOutput, typeof(WaveConditionsOutputProperties));
            Assert.AreEqual(waveImpactOutput.Length, properties.WaveImpactOutput.Length);
            WaveConditionsOutputProperties waveImpactProperties = properties.WaveImpactOutput[0];

            Assert.AreSame(waveImpactOutput[0], waveImpactProperties.Data);

            CollectionAssert.AllItemsAreInstancesOfType(properties.WaveImpactWithWaveDirectionOutput, typeof(WaveConditionsOutputProperties));
            Assert.AreEqual(waveImpactWithWaveDirectionOutput.Length, properties.WaveImpactWithWaveDirectionOutput.Length);
            WaveConditionsOutputProperties waveImpactWithWaveDirectionOutputProperties = properties.WaveImpactWithWaveDirectionOutput[0];

            Assert.AreSame(waveImpactWithWaveDirectionOutput[0], waveImpactWithWaveDirectionOutputProperties.Data);
        }
示例#13
0
        public void Clone_WithOutputSet_ReturnNewInstanceWithCopiedValues()
        {
            // Setup
            var original = new GrassCoverErosionOutwardsWaveConditionsOutput(new[]
            {
                WaveConditionsTestDataGenerator.GetRandomWaveConditionsOutput()
            },
                                                                             new[]
            {
                WaveConditionsTestDataGenerator.GetRandomWaveConditionsOutput()
            },
                                                                             new[]
            {
                WaveConditionsTestDataGenerator.GetRandomWaveConditionsOutput()
            }
                                                                             );

            // Call
            object clone = original.Clone();

            // Assert
            CoreCloneAssert.AreObjectClones(original, clone, GrassCoverErosionOutwardsCloneAssert.AreClones);
        }
        public void IsEnabled_CalculationWithOrWithoutOutputInSubFolder_ReturnExpectedEnabledState(bool hasOutput)
        {
            // Setup
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism();
            var calculationGroup = new CalculationGroup();

            GrassCoverErosionOutwardsWaveConditionsOutput grassCoverErosionOutwardsWaveConditionsOutput = null;

            if (hasOutput)
            {
                grassCoverErosionOutwardsWaveConditionsOutput = GrassCoverErosionOutwardsWaveConditionsOutputTestFactory.Create();
            }

            calculationGroup.Children.Add(
                new CalculationGroup
            {
                Children =
                {
                    new GrassCoverErosionOutwardsWaveConditionsCalculation
                    {
                        Output = grassCoverErosionOutwardsWaveConditionsOutput
                    }
                }
            });

            var context = new GrassCoverErosionOutwardsCalculationGroupContext(calculationGroup, null, failureMechanism, assessmentSection);

            // Call
            bool isEnabled = info.IsEnabled(context);

            // Assert
            Assert.AreEqual(hasOutput, isEnabled);
        }
 /// <summary>
 /// Method that asserts whether <paramref name="original"/> and <paramref name="clone"/>
 /// are clones.
 /// </summary>
 /// <param name="original">The original object.</param>
 /// <param name="clone">The cloned object.</param>
 /// <exception cref="AssertionException">Thrown when <paramref name="original"/> and
 /// <paramref name="clone"/> are not clones.</exception>
 public static void AreClones(GrassCoverErosionOutwardsWaveConditionsOutput original, GrassCoverErosionOutwardsWaveConditionsOutput clone)
 {
     CoreCloneAssert.AreEnumerationClones(original.WaveRunUpOutput, clone.WaveRunUpOutput, WaveConditionsCloneAssert.AreClones);
     CoreCloneAssert.AreEnumerationClones(original.WaveImpactOutput, clone.WaveImpactOutput, WaveConditionsCloneAssert.AreClones);
     CoreCloneAssert.AreEnumerationClones(original.WaveImpactWithWaveDirectionOutput, clone.WaveImpactWithWaveDirectionOutput, WaveConditionsCloneAssert.AreClones);
 }