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

            mocks.ReplayAll();

            var failureMechanism = new DuneErosionFailureMechanism();

            string sourcePath = TestHelper.GetScratchPadPath();

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

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

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

                // Assert
                Assert.IsTrue(isEnabled);
            }

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

            mocks.ReplayAll();

            var failureMechanism = new DuneErosionFailureMechanism();
            var context          = new DuneErosionFailureMechanismContext(failureMechanism, assessmentSection);

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

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

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

            mocks.VerifyAll();
        }
        public void ChildNodeObjects_FailureMechanismInAssemblyFalse_ReturnChildDataNodes()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var failureMechanism = new DuneErosionFailureMechanism
            {
                InAssembly = false
            };
            var context = new DuneErosionFailureMechanismContext(failureMechanism, assessmentSection);

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

                // Call
                object[] children = info.ChildNodeObjects(context).ToArray();

                // Assert
                Assert.AreEqual(1, children.Length);

                var comment = (Comment)children[0];
                Assert.AreSame(failureMechanism.NotInAssemblyComments, comment);
            }

            mocks.VerifyAll();
        }
Esempio n. 4
0
        public void Initialized_Always_ExpectedPropertiesSet()
        {
            // Setup
            using (var plugin = new DuneErosionPlugin())
            {
                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.IsNotNull(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.IsNotNull(info.CanDrop);
                Assert.IsNotNull(info.CanInsert);
                Assert.IsNotNull(info.OnDrop);
            }
        }
        public void CreateInstance_WithContext_SetsDataCorrectly()
        {
            // Setup
            var mockRepository    = new MockRepository();
            var assessmentSection = mockRepository.Stub <IAssessmentSection>();

            mockRepository.ReplayAll();

            var context = new DuneLocationCalculationsForUserDefinedTargetProbabilityContext(new DuneLocationCalculationsForTargetProbability(0.1),
                                                                                             new DuneErosionFailureMechanism(),
                                                                                             assessmentSection);

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

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

                // Assert
                Assert.IsInstanceOf <DuneLocationCalculationsForUserDefinedTargetProbabilityProperties>(objectProperties);
                Assert.AreSame(context.WrappedData, objectProperties.Data);
            }

            mockRepository.VerifyAll();
        }
Esempio n. 6
0
        public void ForeColor_DuneLocationsPresent_ReturnControlText()
        {
            // Setup
            var failureMechanism = new DuneErosionFailureMechanism();

            failureMechanism.SetDuneLocations(new[]
            {
                new TestDuneLocation()
            });

            var calculationsGroupContext = new DuneLocationCalculationsForUserDefinedTargetProbabilitiesGroupContext(
                new ObservableList <DuneLocationCalculationsForTargetProbability>(),
                failureMechanism,
                new AssessmentSectionStub());

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

                // Call
                Color textColor = info.ForeColor(calculationsGroupContext);

                // Assert
                Assert.AreEqual(Color.FromKnownColor(KnownColor.ControlText), textColor);
            }
        }
Esempio n. 7
0
        public void CurrentPath_FailureMechanismSectionsSourcePathSet_ReturnsExpectedPath()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var failureMechanism = new DuneErosionFailureMechanism();

            string sourcePath = TestHelper.GetScratchPadPath();

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

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

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

                // Assert
                Assert.AreEqual(sourcePath, currentFilePath);
                mocks.VerifyAll();
            }
        }
Esempio n. 8
0
        public void GetPropertyInfos_ReturnsSupportedPropertyInfos()
        {
            // Setup
            using (var plugin = new DuneErosionPlugin())
            {
                // 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(DuneLocationCalculationsForUserDefinedTargetProbabilityContext),
                    typeof(DuneLocationCalculationsForUserDefinedTargetProbabilityProperties));
                PluginTestHelper.AssertPropertyInfoDefined(
                    propertyInfos,
                    typeof(DuneLocationCalculation),
                    typeof(DuneLocationCalculationProperties));
            }
        }
        public void CreateFileExporter_Always_ReturnFileExporter()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var context = new DuneLocationCalculationsForUserDefinedTargetProbabilitiesGroupContext(new ObservableList <DuneLocationCalculationsForTargetProbability>(),
                                                                                                    new DuneErosionFailureMechanism(),
                                                                                                    assessmentSection);

            using (var plugin = new DuneErosionPlugin())
            {
                ExportInfo info = GetExportInfo(plugin);

                // Call
                IFileExporter fileExporter = info.CreateFileExporter(context, "test");

                // Assert
                Assert.IsInstanceOf <DuneLocationCalculationsExporter>(fileExporter);
            }

            mocks.VerifyAll();
        }
        public void IsEnabled_CalculationsWithoutOutput_ReturnFalse()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var failureMechanism = new DuneErosionFailureMechanism();

            failureMechanism.SetDuneLocations(new[]
            {
                new TestDuneLocation()
            });
            var context = new DuneLocationCalculationsForUserDefinedTargetProbabilitiesGroupContext(new ObservableList <DuneLocationCalculationsForTargetProbability>(),
                                                                                                    failureMechanism,
                                                                                                    assessmentSection);

            using (var plugin = new DuneErosionPlugin())
            {
                ExportInfo info = GetExportInfo(plugin);

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

                // Assert
                Assert.IsFalse(isEnabled);
            }

            mocks.VerifyAll();
        }
        public void CloseViewForData_ViewDataNull_ReturnsFalse()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            using (var plugin = new DuneErosionPlugin())
                using (var view = new DuneLocationCalculationsView(new ObservableList <DuneLocationCalculation>(),
                                                                   new DuneErosionFailureMechanism(),
                                                                   assessmentSection,
                                                                   () => 0.01,
                                                                   () => "1/100"))
                {
                    ViewInfo info = GetInfo(plugin);

                    // Call
                    bool closeForData = info.CloseForData(view, null);

                    // Assert
                    Assert.IsFalse(closeForData);
                }

            mocks.VerifyAll();
        }
        public void CloseViewForData_ForOtherObjectType_ReturnsFalse()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            assessmentSection.Stub(a => a.GetFailureMechanisms()).Return(new[]
            {
                new DuneErosionFailureMechanism()
            });
            assessmentSection.Stub(a => a.Attach(null)).IgnoreArguments();
            assessmentSection.Stub(a => a.Detach(null)).IgnoreArguments();
            mocks.ReplayAll();

            using (var plugin = new DuneErosionPlugin())
                using (var view = new DuneLocationCalculationsView(new ObservableList <DuneLocationCalculation>(),
                                                                   new DuneErosionFailureMechanism(),
                                                                   assessmentSection,
                                                                   () => 0.01,
                                                                   () => "1/100"))
                {
                    ViewInfo info = GetInfo(plugin);

                    // Call
                    bool closeForData = info.CloseForData(view, new object());

                    // Assert
                    Assert.IsFalse(closeForData);
                }

            mocks.VerifyAll();
        }
        public void CreateInstance_WithContext_SetsExpectedProperties()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();
            var window            = mocks.Stub <IMainWindow>();
            var gui = mocks.Stub <IGui>();

            gui.Stub(g => g.MainWindow).Return(window);
            gui.Stub(g => g.ViewHost).Return(mocks.Stub <IViewHost>());
            mocks.ReplayAll();

            var failureMechanism = new DuneErosionFailureMechanism();
            var context          = new DuneLocationCalculationsForUserDefinedTargetProbabilityContext(new DuneLocationCalculationsForTargetProbability(0.1),
                                                                                                      failureMechanism,
                                                                                                      assessmentSection);

            using (var plugin = new DuneErosionPlugin())
            {
                ViewInfo info = GetInfo(plugin);

                plugin.Gui = gui;
                plugin.Activate();

                // Call
                using (var view = info.CreateInstance(context) as DuneLocationCalculationsView)
                {
                    // Assert
                    Assert.AreSame(assessmentSection, view.AssessmentSection);
                    Assert.AreSame(failureMechanism, view.FailureMechanism);
                }
            }

            mocks.VerifyAll();
        }
Esempio n. 14
0
        public void CanDrop_DraggedDataPartOfGroupContext_ReturnsTrue()
        {
            // Setup
            using (var plugin = new DuneErosionPlugin())
            {
                TreeNodeInfo info = GetInfo(plugin);

                var assessmentSectionStub            = new AssessmentSectionStub();
                var failureMechanism                 = new DuneErosionFailureMechanism();
                var calculationsForTargetProbability = new DuneLocationCalculationsForTargetProbability(0.1);

                var targetData = new DuneLocationCalculationsForUserDefinedTargetProbabilitiesGroupContext(
                    new ObservableList <DuneLocationCalculationsForTargetProbability>
                {
                    calculationsForTargetProbability
                },
                    failureMechanism,
                    assessmentSectionStub);

                var draggedData = new DuneLocationCalculationsForUserDefinedTargetProbabilityContext(
                    calculationsForTargetProbability,
                    failureMechanism,
                    assessmentSectionStub);

                // Call
                bool canDrop = info.CanDrop(draggedData, targetData);

                // Assert
                Assert.IsTrue(canDrop);
            }
        }
Esempio n. 15
0
        public void ChildNodeObjects_NoDuneLocationsPresent_ReturnsExpectedChildData()
        {
            // Setup
            var duneLocationCalculationsForTargetProbability1 = new DuneLocationCalculationsForTargetProbability(0.1);
            var duneLocationCalculationsForTargetProbability2 = new DuneLocationCalculationsForTargetProbability(0.01);

            var calculationsForTargetProbabilities = new ObservableList <DuneLocationCalculationsForTargetProbability>
            {
                duneLocationCalculationsForTargetProbability1,
                duneLocationCalculationsForTargetProbability2
            };

            var calculationsGroupContext = new DuneLocationCalculationsForUserDefinedTargetProbabilitiesGroupContext(calculationsForTargetProbabilities,
                                                                                                                     new DuneErosionFailureMechanism(),
                                                                                                                     new AssessmentSectionStub());

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

                // Call
                object[] childNodeObjects = info.ChildNodeObjects(calculationsGroupContext);

                // Assert
                CollectionAssert.IsEmpty(childNodeObjects);
            }
        }
Esempio n. 16
0
 public void DefaultConstructor_ExpectedValues()
 {
     // Call
     using (var plugin = new DuneErosionPlugin())
     {
         // Assert
         Assert.IsInstanceOf <PluginBase>(plugin);
     }
 }
Esempio n. 17
0
        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.ViewHost).Return(mockRepository.Stub <IViewHost>());
            gui.Stub(g => g.ActiveStateInfo).Return(new StateInfo(string.Empty, symbol, fontFamily, p => p));
            mockRepository.ReplayAll();

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

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

                PluginTestHelper.AssertViewInfoDefined(
                    viewInfos,
                    typeof(DuneErosionFailureMechanismSectionResultContext),
                    typeof(IObservableEnumerable <NonAdoptableFailureMechanismSectionResult>),
                    typeof(NonAdoptableFailureMechanismResultView <DuneErosionFailureMechanism>));

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

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

                PluginTestHelper.AssertViewInfoDefined(
                    viewInfos,
                    typeof(DuneLocationCalculationsForUserDefinedTargetProbabilityContext),
                    typeof(IObservableEnumerable <DuneLocationCalculation>),
                    typeof(DuneLocationCalculationsView));

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

            mockRepository.VerifyAll();
        }
Esempio n. 18
0
        public void ContextMenuStrip_ClickOnAddTargetProbabilityItem_CalculationsForTargetProbabilityAddedAndObserversNotified()
        {
            // Given
            var failureMechanism = new DuneErosionFailureMechanism();

            failureMechanism.SetDuneLocations(new[]
            {
                new TestDuneLocation("Location 1"),
                new TestDuneLocation("Location 2")
            });

            var calculations = new ObservableList <DuneLocationCalculationsForTargetProbability>();
            var context      = new DuneLocationCalculationsForUserDefinedTargetProbabilitiesGroupContext(calculations,
                                                                                                         failureMechanism,
                                                                                                         new AssessmentSectionStub());

            var mockRepository       = new MockRepository();
            var calculationsObserver = mockRepository.StrictMock <IObserver>();

            calculationsObserver.Expect(o => o.UpdateObserver());
            calculations.Attach(calculationsObserver);

            using (var treeViewControl = new TreeViewControl())
            {
                IMainWindow mainWindow = MainWindowTestHelper.CreateMainWindowStub(mockRepository);

                IGui gui = StubFactory.CreateGuiStub(mockRepository);
                gui.Stub(g => g.MainWindow).Return(mainWindow);
                gui.Stub(cmp => cmp.Get(context, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder());

                mockRepository.ReplayAll();

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

                    using (ContextMenuStrip contextMenuAdapter = info.ContextMenuStrip(context, null, treeViewControl))
                    {
                        // When
                        contextMenuAdapter.Items[contextMenuAddTargetProbabilityIndex].PerformClick();

                        // Then
                        Assert.AreEqual(1, calculations.Count);
                        Assert.AreEqual(0.01, calculations[0].TargetProbability);
                        Assert.AreEqual(2, calculations[0].DuneLocationCalculations.Count);
                    }
                }
            }

            mockRepository.VerifyAll();
        }
Esempio n. 19
0
        public void ContextMenuStrip_Always_CallsContextMenuBuilderMethods()
        {
            // Setup
            var mockRepository = new MockRepository();
            IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(mockRepository);

            var orderedMockRepository = new MockRepository();
            var menuBuilder           = orderedMockRepository.StrictMock <IContextMenuBuilder>();

            using (orderedMockRepository.Ordered())
            {
                menuBuilder.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilder);
                menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder);
                menuBuilder.Expect(mb => mb.AddExportItem()).Return(menuBuilder);
                menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder);
                menuBuilder.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilder);
                menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder);
                menuBuilder.Expect(mb => mb.AddDeleteChildrenItem()).Return(menuBuilder);
                menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder);
                menuBuilder.Expect(mb => mb.AddCollapseAllItem()).Return(menuBuilder);
                menuBuilder.Expect(mb => mb.AddExpandAllItem()).Return(menuBuilder);
                menuBuilder.Expect(mb => mb.Build()).Return(null);
            }

            orderedMockRepository.ReplayAll();

            var nodeData = new DuneLocationCalculationsForUserDefinedTargetProbabilitiesGroupContext(
                new ObservableList <DuneLocationCalculationsForTargetProbability>(),
                new DuneErosionFailureMechanism(),
                assessmentSection);

            using (var treeViewControl = new TreeViewControl())
            {
                var gui = mockRepository.Stub <IGui>();
                gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilder);
                gui.Stub(g => g.ViewHost).Return(mockRepository.Stub <IViewHost>());
                mockRepository.ReplayAll();

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

                    plugin.Gui = gui;

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

            // Assert
            orderedMockRepository.VerifyAll();
            mockRepository.VerifyAll();
        }
        public void Initialized_Always_ExpectedPropertiesSet()
        {
            // Setup
            using (var plugin = new DuneErosionPlugin())
            {
                // Call
                PropertyInfo info = GetInfo(plugin);

                // Assert
                Assert.AreEqual(typeof(DuneLocationCalculationsForUserDefinedTargetProbabilityProperties), info.PropertyObjectType);
            }
        }
Esempio n. 21
0
        public void OnDrop_DataDroppedToDifferentIndex_DroppedDataCorrectlyMovedAndObserversNotified()
        {
            // Setup
            using (var plugin = new DuneErosionPlugin())
            {
                TreeNodeInfo info = GetInfo(plugin);

                var assessmentSectionStub = new AssessmentSectionStub();
                var failureMechanism      = new DuneErosionFailureMechanism();

                var calculationsForTargetProbability1 = new DuneLocationCalculationsForTargetProbability(0.1);
                var calculationsForTargetProbability2 = new DuneLocationCalculationsForTargetProbability(0.01);
                var calculationsForTargetProbability3 = new DuneLocationCalculationsForTargetProbability(0.001);

                var calculationsForTargetProbabilities = new ObservableList <DuneLocationCalculationsForTargetProbability>
                {
                    calculationsForTargetProbability1,
                    calculationsForTargetProbability2,
                    calculationsForTargetProbability3
                };

                var parentData = new DuneLocationCalculationsForUserDefinedTargetProbabilitiesGroupContext(
                    calculationsForTargetProbabilities,
                    failureMechanism,
                    assessmentSectionStub);

                var droppedData = new DuneLocationCalculationsForUserDefinedTargetProbabilityContext(
                    calculationsForTargetProbability3,
                    failureMechanism,
                    assessmentSectionStub);

                var mockRepository = new MockRepository();
                var observer       = mockRepository.StrictMock <IObserver>();
                observer.Expect(o => o.UpdateObserver());
                mockRepository.ReplayAll();

                calculationsForTargetProbabilities.Attach(observer);

                // Call
                info.OnDrop(droppedData, parentData, parentData, 1, null);

                // Assert
                CollectionAssert.AreEquivalent(new[]
                {
                    calculationsForTargetProbability1,
                    calculationsForTargetProbability3,
                    calculationsForTargetProbability2
                }, calculationsForTargetProbabilities);

                mockRepository.VerifyAll();
            }
        }
Esempio n. 22
0
        public void Initialized_Always_ExpectedPropertiesSet()
        {
            // Setup
            using (var plugin = new DuneErosionPlugin())
            {
                // Call
                PropertyInfo info = GetInfo(plugin);

                // Assert
                Assert.AreEqual(typeof(DuneErosionFailureMechanismContext), info.DataType);
                Assert.AreEqual(typeof(DuneErosionFailureMechanismProperties), info.PropertyObjectType);
            }
        }
Esempio n. 23
0
        public void Activate_GuiNull_ThrowInvalidOperationException()
        {
            // Setup
            using (var plugin = new DuneErosionPlugin())
            {
                // Call
                void Call() => plugin.Activate();

                // Assert
                var exception = Assert.Throws <InvalidOperationException>(Call);
                Assert.AreEqual("Gui cannot be null", exception.Message);
            }
        }
Esempio n. 24
0
        public void GetUpdateInfos_ReturnsSupportedUpdateInfos()
        {
            // Setup
            using (var plugin = new DuneErosionPlugin())
            {
                // Call
                UpdateInfo[] updateInfos = plugin.GetUpdateInfos().ToArray();

                // Assert
                Assert.AreEqual(1, updateInfos.Length);
                Assert.IsTrue(updateInfos.Any(ei => ei.DataType == typeof(DuneErosionFailureMechanismSectionsContext)));
            }
        }
Esempio n. 25
0
        public void ContextMenuStrip_Always_AddCustomItems()
        {
            // Setup
            IAssessmentSection assessmentSection = new AssessmentSectionStub();

            var menuBuilder = new CustomItemsOnlyContextMenuBuilder();

            var nodeData = new DuneLocationCalculationsForUserDefinedTargetProbabilitiesGroupContext(
                new ObservableList <DuneLocationCalculationsForTargetProbability>(),
                new DuneErosionFailureMechanism(),
                assessmentSection);

            var mockRepository = new MockRepository();

            using (var treeViewControl = new TreeViewControl())
            {
                IGui gui = StubFactory.CreateGuiStub(mockRepository);
                gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilder);
                gui.Stub(cmp => cmp.MainWindow).Return(mockRepository.Stub <IMainWindow>());
                mockRepository.ReplayAll();

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

                    plugin.Gui = gui;

                    // Call
                    using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, assessmentSection, treeViewControl))
                    {
                        // Assert
                        Assert.AreEqual(10, menu.Items.Count);

                        TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuAddTargetProbabilityIndex,
                                                                      "Doelkans toevoegen",
                                                                      "Voeg een nieuwe doelkans toe aan deze map.",
                                                                      RiskeerCommonFormsResources.GenericInputOutputIcon,
                                                                      false);

                        TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuCalculateAllIndex,
                                                                      "Alles be&rekenen",
                                                                      "Er is geen hydraulische belastingendatabase geïmporteerd.",
                                                                      RiskeerCommonFormsResources.CalculateAllIcon,
                                                                      false);
                    }
                }
            }

            // Assert
            mockRepository.VerifyAll();
        }
        public void ViewDataType_Always_ReturnsViewDataType()
        {
            // Setup
            using (var plugin = new DuneErosionPlugin())
            {
                ViewInfo info = GetInfo(plugin);

                // Call
                Type viewDataType = info.ViewDataType;

                // Assert
                Assert.AreEqual(typeof(IObservableEnumerable <DuneLocationCalculation>), viewDataType);
            }
        }
        public void Name_Always_ReturnsName()
        {
            // Setup
            using (var plugin = new DuneErosionPlugin())
            {
                ExportInfo info = GetExportInfo(plugin);

                // Call
                string name = info.Name(null);

                // Assert
                Assert.AreEqual("Hydraulische belastingen", name);
            }
        }
Esempio n. 28
0
        public void GetExportInfos_ReturnsSupportedExportInfos()
        {
            // Setup
            using (var plugin = new DuneErosionPlugin())
            {
                // Call
                ExportInfo[] exportInfos = plugin.GetExportInfos().ToArray();

                // Assert
                Assert.AreEqual(2, exportInfos.Length);
                Assert.IsTrue(exportInfos.Any(ei => ei.DataType == typeof(DuneLocationCalculationsForUserDefinedTargetProbabilityContext)));
                Assert.IsTrue(exportInfos.Any(ei => ei.DataType == typeof(DuneLocationCalculationsForUserDefinedTargetProbabilitiesGroupContext)));
            }
        }
Esempio n. 29
0
        public void Image_Always_ReturnsGeneralFolderIcon()
        {
            // Setup
            using (var plugin = new DuneErosionPlugin())
            {
                TreeNodeInfo info = GetInfo(plugin);

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

                // Assert
                TestHelper.AssertImagesAreEqual(RiskeerCommonFormsResources.GeneralFolderIcon, image);
            }
        }
Esempio n. 30
0
        public void Text_Always_ReturnsSetName()
        {
            // Setup
            using (var plugin = new DuneErosionPlugin())
            {
                TreeNodeInfo info = GetInfo(plugin);

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

                // Assert
                Assert.AreEqual("Hydraulische belastingen", text);
            }
        }