Esempio n. 1
0
        public void CurrentPath_FailureMechanismSectionsSourcePathSet_ReturnsExpectedPath()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism();

            string sourcePath = TestHelper.GetScratchPadPath();

            failureMechanism.SetSections(Enumerable.Empty <FailureMechanismSection>(), sourcePath);
            var context = new WaveImpactAsphaltCoverFailureMechanismSectionsContext(failureMechanism, assessmentSection);

            using (var plugin = new WaveImpactAsphaltCoverPlugin())
            {
                UpdateInfo updateInfo = GetUpdateInfo(plugin);

                // Call
                string currentFilePath = updateInfo.CurrentPath(context);

                // Assert
                Assert.AreEqual(sourcePath, currentFilePath);
                mocks.VerifyAll();
            }
        }
Esempio n. 2
0
        public void CreateInstance_WithContextThatHasInputWithSpecificWaterLevelType_ExpectedProperties(
            IAssessmentSection assessmentSection,
            Action <WaveConditionsInput> configureInputAction,
            RoundedDouble expectedAssessmentLevel)
        {
            // Setup
            var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation();

            configureInputAction(calculation.InputParameters);

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

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

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

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

                Assert.AreEqual(expectedAssessmentLevel, ((WaveImpactAsphaltCoverWaveConditionsInputContextProperties)objectProperties).AssessmentLevel);
            }
        }
        public void CreateInstance_WithContext_SetsFailureMechanismAsData()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism();
            var context          = new WaveImpactAsphaltCoverFailureMechanismContext(failureMechanism, assessmentSection);

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

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

                // Assert
                Assert.IsInstanceOf <WaveImpactAsphaltCoverFailureMechanismProperties>(objectProperties);
                Assert.AreSame(failureMechanism, objectProperties.Data);
            }

            mocks.VerifyAll();
        }
        public void Initialized_Always_ExpectedPropertiesSet()
        {
            // Setup
            using (var plugin = new WaveImpactAsphaltCoverPlugin())
            {
                TreeNodeInfo info = GetInfo(plugin);

                // Assert
                Assert.IsNotNull(info.Text);
                Assert.IsNotNull(info.ForeColor);
                Assert.IsNotNull(info.Image);
                Assert.IsNotNull(info.ContextMenuStrip);
                Assert.IsNull(info.EnsureVisibleOnCreate);
                Assert.IsNull(info.ExpandOnCreate);
                Assert.IsNull(info.ChildNodeObjects);
                Assert.IsNull(info.CanRename);
                Assert.IsNull(info.OnNodeRenamed);
                Assert.IsNull(info.CanRemove);
                Assert.IsNull(info.OnNodeRemoved);
                Assert.IsNull(info.CanCheck);
                Assert.IsNull(info.CheckedState);
                Assert.IsNull(info.OnNodeChecked);
                Assert.IsNull(info.CanDrag);
                Assert.IsNull(info.CanDrop);
                Assert.IsNull(info.CanInsert);
                Assert.IsNull(info.OnDrop);
            }
        }
        public void GetExportInfos_ReturnsSupportedExportInfos()
        {
            // Setup
            var mocks      = new MockRepository();
            var mainWindow = mocks.Stub <IMainWindow>();
            var gui        = mocks.Stub <IGui>();

            gui.Stub(g => g.MainWindow).Return(mainWindow);
            mocks.ReplayAll();

            using (var plugin = new WaveImpactAsphaltCoverPlugin
            {
                Gui = gui
            })
            {
                // Call
                ExportInfo[] exportInfos = plugin.GetExportInfos().ToArray();

                // Assert
                Assert.AreEqual(4, exportInfos.Length);
                Assert.AreEqual(2, exportInfos.Count(ei => ei.DataType == typeof(WaveImpactAsphaltCoverCalculationGroupContext)));
                Assert.AreEqual(2, exportInfos.Count(ei => ei.DataType == typeof(WaveImpactAsphaltCoverWaveConditionsCalculationContext)));
            }

            mocks.VerifyAll();
        }
        public void GetPropertyInfos_ReturnsSupportedPropertyInfos()
        {
            // Setup
            using (var plugin = new WaveImpactAsphaltCoverPlugin())
            {
                // Call
                PropertyInfo[] propertyInfos = plugin.GetPropertyInfos().ToArray();

                // Assert
                Assert.AreEqual(4, propertyInfos.Length);

                PluginTestHelper.AssertPropertyInfoDefined(
                    propertyInfos,
                    typeof(HydraulicLoadsStateFailureMechanismContext),
                    typeof(HydraulicLoadsStateFailureMechanismProperties));

                PluginTestHelper.AssertPropertyInfoDefined(
                    propertyInfos,
                    typeof(RegistrationStateFailureMechanismContext),
                    typeof(RegistrationStateFailureMechanismProperties));

                PluginTestHelper.AssertPropertyInfoDefined(
                    propertyInfos,
                    typeof(WaveImpactAsphaltCoverWaveConditionsOutput),
                    typeof(WaveImpactAsphaltCoverWaveConditionsOutputProperties));

                PluginTestHelper.AssertPropertyInfoDefined(
                    propertyInfos,
                    typeof(WaveImpactAsphaltCoverWaveConditionsInputContext),
                    typeof(WaveImpactAsphaltCoverWaveConditionsInputContextProperties));
            }
        }
        public void ContextMenuStrip_Always_CallsContextMenuBuilderMethods()
        {
            // Setup
            var mocks = new MockRepository();

            using (var treeViewControl = new TreeViewControl())
            {
                var output = new EmptyWaveImpactAsphaltCoverOutput();

                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(output, treeViewControl)).Return(menuBuilder);
                mocks.ReplayAll();

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

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

            // Assert
            mocks.VerifyAll();
        }
Esempio n. 8
0
        public void IsEnabled_FailureMechanismSectionsSourcePathSet_ReturnTrue()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism();

            string sourcePath = TestHelper.GetScratchPadPath();

            failureMechanism.SetSections(Enumerable.Empty <FailureMechanismSection>(), sourcePath);
            var context = new WaveImpactAsphaltCoverFailureMechanismSectionsContext(failureMechanism, assessmentSection);

            using (var plugin = new WaveImpactAsphaltCoverPlugin())
            {
                UpdateInfo importInfo = GetUpdateInfo(plugin);

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

                // Assert
                Assert.IsTrue(isEnabled);
            }

            mocks.VerifyAll();
        }
 public void DefaultConstructor_ExpectedValues()
 {
     // Call
     using (var plugin = new WaveImpactAsphaltCoverPlugin())
     {
         // Assert
         Assert.IsInstanceOf <PluginBase>(plugin);
     }
 }
        public void GetViewInfos_ReturnsSupportedViewInfos()
        {
            // Setup
            const string symbol     = "<symbol>";
            var          fontFamily = new FontFamily();

            var mockRepository = new MockRepository();
            var gui            = mockRepository.Stub <IGui>();

            gui.Stub(g => g.ActiveStateInfo).Return(new StateInfo(string.Empty, symbol, fontFamily, p => p));
            mockRepository.ReplayAll();

            using (var plugin = new WaveImpactAsphaltCoverPlugin
            {
                Gui = gui
            })
            {
                // Call
                ViewInfo[] viewInfos = plugin.GetViewInfos().ToArray();

                // Assert
                Assert.AreEqual(4, viewInfos.Length);

                PluginTestHelper.AssertViewInfoDefined(
                    viewInfos,
                    typeof(HydraulicLoadsStateFailureMechanismContext),
                    typeof(HydraulicLoadsStateFailureMechanismView));

                PluginTestHelper.AssertViewInfoDefined(
                    viewInfos,
                    typeof(RegistrationStateFailureMechanismContext),
                    typeof(RegistrationStateFailureMechanismView));

                PluginTestHelper.AssertViewInfoDefined(
                    viewInfos,
                    typeof(WaveImpactAsphaltCoverFailureMechanismSectionResultContext),
                    typeof(IObservableEnumerable <NonAdoptableWithProfileProbabilityFailureMechanismSectionResult>),
                    typeof(NonAdoptableWithProfileProbabilityFailureMechanismResultView <WaveImpactAsphaltCoverFailureMechanism>));

                PluginTestHelper.AssertViewInfoDefined(
                    viewInfos,
                    typeof(WaveImpactAsphaltCoverWaveConditionsInputContext),
                    typeof(ICalculation <WaveConditionsInput>),
                    typeof(WaveConditionsInputView));

                viewInfos.ForEachElementDo(vi =>
                {
                    Assert.AreEqual(symbol, vi.GetSymbol());
                    Assert.AreSame(fontFamily, vi.GetFontFamily());
                });
            }

            mockRepository.VerifyAll();
        }
        public void GetUpdateInfos_ReturnsSupportedUpdateInfos()
        {
            // Setup
            using (var plugin = new WaveImpactAsphaltCoverPlugin())
            {
                // Call
                UpdateInfo[] updateInfos = plugin.GetUpdateInfos().ToArray();

                // Assert
                Assert.AreEqual(1, updateInfos.Length);
                Assert.AreEqual(1, updateInfos.Count(ei => ei.DataType == typeof(WaveImpactAsphaltCoverFailureMechanismSectionsContext)));
            }
        }
        public void GetImportInfos_ReturnsSupportedImportInfos()
        {
            // Setup
            using (var plugin = new WaveImpactAsphaltCoverPlugin())
            {
                // Call
                ImportInfo[] importInfos = plugin.GetImportInfos().ToArray();

                // Assert
                Assert.AreEqual(1, importInfos.Length);
                Assert.IsTrue(importInfos.Any(i => i.DataType == typeof(WaveImpactAsphaltCoverCalculationGroupContext)));
            }
        }
        public void Initialized_Always_ExpectedPropertiesSet()
        {
            // Setup
            using (var plugin = new WaveImpactAsphaltCoverPlugin())
            {
                // Call
                PropertyInfo info = GetInfo(plugin);

                // Assert
                Assert.AreEqual(typeof(WaveImpactAsphaltCoverFailureMechanismContext), info.DataType);
                Assert.AreEqual(typeof(WaveImpactAsphaltCoverFailureMechanismProperties), info.PropertyObjectType);
            }
        }
        public void Image_Always_ReturnOutputIcon()
        {
            // Setup
            using (var plugin = new WaveImpactAsphaltCoverPlugin())
            {
                TreeNodeInfo info = GetInfo(plugin);

                // Call
                Image icon = info.Image(null);

                // Assert
                TestHelper.AssertImagesAreEqual(Resources.GenericInputOutputIcon, icon);
            }
        }
Esempio n. 15
0
        public void Image_Always_ReturnExpectedIcon()
        {
            // Setup
            using (var plugin = new WaveImpactAsphaltCoverPlugin())
            {
                UpdateInfo importInfo = GetUpdateInfo(plugin);

                // Call
                Image image = importInfo.Image;

                // Assert
                TestHelper.AssertImagesAreEqual(RiskeerCommonFormsResources.SectionsIcon, image);
            }
        }
Esempio n. 16
0
        public void Name_Always_ReturnExpectedName()
        {
            // Setup
            using (var plugin = new WaveImpactAsphaltCoverPlugin())
            {
                UpdateInfo importInfo = GetUpdateInfo(plugin);

                // Call
                string name = importInfo.Name;

                // Assert
                Assert.AreEqual("Vakindeling", name);
            }
        }
        public void Text_Always_ReturnName()
        {
            // Setup
            using (var plugin = new WaveImpactAsphaltCoverPlugin())
            {
                TreeNodeInfo info = GetInfo(plugin);

                // Call
                string nodeText = info.Text(null);

                // Assert
                Assert.AreEqual("Invoer", nodeText);
            }
        }
Esempio n. 18
0
        public void FileFilterGenerator_Always_ReturnExpectedFileFilter()
        {
            // Setup
            using (var plugin = new WaveImpactAsphaltCoverPlugin())
            {
                UpdateInfo importInfo = GetUpdateInfo(plugin);

                // Call
                FileFilterGenerator fileFilterGenerator = importInfo.FileFilterGenerator;

                // Assert
                Assert.AreEqual("Shapebestand (*.shp)|*.shp", fileFilterGenerator.Filter);
            }
        }
Esempio n. 19
0
        public void Category_Always_ReturnExpectedCategory()
        {
            // Setup
            using (var plugin = new WaveImpactAsphaltCoverPlugin())
            {
                UpdateInfo importInfo = GetUpdateInfo(plugin);

                // Call
                string category = importInfo.Category;

                // Assert
                Assert.AreEqual("Algemeen", category);
            }
        }
        public void Image_Always_ReturnOutputIcon()
        {
            // Setup
            var output = new EmptyWaveImpactAsphaltCoverOutput();

            using (var plugin = new WaveImpactAsphaltCoverPlugin())
            {
                TreeNodeInfo info = GetInfo(plugin);
                // Call
                Image icon = info.Image(output);

                // Assert
                TestHelper.AssertImagesAreEqual(RiskeerCommonFormsResources.GeneralOutputIcon, icon);
            }
        }
        public void Text_Always_ReturnName()
        {
            // Setup
            var output = new EmptyWaveImpactAsphaltCoverOutput();

            using (var plugin = new WaveImpactAsphaltCoverPlugin())
            {
                TreeNodeInfo info = GetInfo(plugin);

                // Call
                string nodeText = info.Text(output);

                // Assert
                Assert.AreEqual("Resultaat", nodeText);
            }
        }
        public void ForeColor_Always_ReturnGrayText()
        {
            // Setup
            var output = new EmptyWaveImpactAsphaltCoverOutput();

            using (var plugin = new WaveImpactAsphaltCoverPlugin())
            {
                TreeNodeInfo info = GetInfo(plugin);

                // Call
                Color color = info.ForeColor(output);

                // Assert
                Assert.AreEqual(Color.FromKnownColor(KnownColor.GrayText), color);
            }
        }
Esempio n. 23
0
        public void SetUp()
        {
            mocks = new MockRepository();
            var mainWindow = mocks.Stub <IMainWindow>();
            var gui        = mocks.Stub <IGui>();

            gui.Stub(g => g.MainWindow).Return(mainWindow);
            mocks.Replay(gui);
            mocks.Replay(mainWindow);

            plugin = new WaveImpactAsphaltCoverPlugin
            {
                Gui = gui
            };

            info = plugin.GetExportInfos()
                   .Single(ei => ei.DataType == typeof(WaveImpactAsphaltCoverWaveConditionsCalculationContext) &&
                           ei.Name(null).Equals("Berekende belastingen bij verschillende waterstanden"));
        }
Esempio n. 24
0
        public void SetUp()
        {
            mocks = new MockRepository();
            var mainWindow = mocks.Stub <IMainWindow>();
            var gui        = mocks.Stub <IGui>();

            gui.Stub(g => g.MainWindow).Return(mainWindow);
            mocks.Replay(gui);
            mocks.Replay(mainWindow);

            plugin = new WaveImpactAsphaltCoverPlugin
            {
                Gui = gui
            };

            info = plugin.GetExportInfos()
                   .Single(ei => ei.DataType == typeof(WaveImpactAsphaltCoverCalculationGroupContext) &&
                           ei.Name(null).Equals("Riskeer berekeningenconfiguratie"));
        }
        public void GetTreeNodeInfos_ReturnsSupportedTreeNodeInfos()
        {
            // Setup
            using (var plugin = new WaveImpactAsphaltCoverPlugin())
            {
                // Call
                TreeNodeInfo[] treeNodeInfos = plugin.GetTreeNodeInfos().ToArray();

                // Assert
                Assert.AreEqual(8, treeNodeInfos.Length);
                Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(HydraulicLoadsStateFailureMechanismContext)));
                Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(RegistrationStateFailureMechanismContext)));
                Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(WaveImpactAsphaltCoverFailureMechanismSectionResultContext)));
                Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(WaveImpactAsphaltCoverCalculationGroupContext)));
                Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(WaveImpactAsphaltCoverWaveConditionsCalculationContext)));
                Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(EmptyWaveImpactAsphaltCoverOutput)));
                Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(WaveImpactAsphaltCoverWaveConditionsOutput)));
                Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(WaveImpactAsphaltCoverWaveConditionsInputContext)));
            }
        }
Esempio n. 26
0
        public void CreateFileImporter_WithValidData_ReturnsFileImporter()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            assessmentSection.Stub(a => a.ReferenceLine).Return(new ReferenceLine());
            mocks.ReplayAll();

            var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism();
            var context          = new WaveImpactAsphaltCoverFailureMechanismSectionsContext(failureMechanism, assessmentSection);

            using (var plugin = new WaveImpactAsphaltCoverPlugin())
            {
                UpdateInfo updateInfo = GetUpdateInfo(plugin);

                // Call
                IFileImporter importer = updateInfo.CreateFileImporter(context, string.Empty);

                // Assert
                Assert.IsInstanceOf <FailureMechanismSectionsImporter>(importer);
                mocks.VerifyAll();
            }
        }
Esempio n. 27
0
        public void IsEnabled_FailureMechanismSectionsSourcePathNull_ReturnFalse()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism();
            var context          = new WaveImpactAsphaltCoverFailureMechanismSectionsContext(failureMechanism, assessmentSection);

            using (var plugin = new WaveImpactAsphaltCoverPlugin())
            {
                UpdateInfo importInfo = GetUpdateInfo(plugin);

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

                // Assert
                Assert.IsFalse(isEnabled);
            }

            mocks.VerifyAll();
        }
 public void SetUp()
 {
     plugin = new WaveImpactAsphaltCoverPlugin();
     info   = plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(WaveImpactAsphaltCoverFailureMechanismSectionResultContext));
 }
 private static PropertyInfo GetInfo(WaveImpactAsphaltCoverPlugin plugin)
 {
     return(plugin.GetPropertyInfos().First(pi => pi.DataType == typeof(WaveImpactAsphaltCoverFailureMechanismContext)));
 }
Esempio n. 30
0
 public void SetUp()
 {
     plugin = new WaveImpactAsphaltCoverPlugin();
     info   = plugin.GetViewInfos().First(tni => tni.ViewType == typeof(WaveConditionsInputView));
 }