// Copyright (C) Stichting Deltares 2017. All rights reserved. // // This file is part of Ringtoets. // // Ringtoets is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . // // All names, logos, and references to "Deltares" are registered trademarks of // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. using System.Linq; using System.Threading; using Core.Common.Controls.TreeView; using Core.Common.Gui.Plugin; using Core.Common.Gui.TestUtil; using NUnit.Framework; using Ringtoets.Common.Forms.PresentationObjects; using Ringtoets.MacroStabilityInwards.Data; using Ringtoets.MacroStabilityInwards.Forms.PresentationObjects; using Ringtoets.MacroStabilityInwards.Forms.PropertyClasses; using Ringtoets.MacroStabilityInwards.Forms.Views; using Ringtoets.MacroStabilityInwards.Primitives; namespace Ringtoets.MacroStabilityInwards.Plugin.Test { [TestFixture] public class MacroStabilityInwardsPluginTest { [Test] [Apartment(ApartmentState.STA)] // For creation of XAML UI component (PipingRibbon) public void DefaultConstructor_ExpectedValues() { // Call using (var plugin = new MacroStabilityInwardsPlugin()) { // Assert Assert.IsInstanceOf(plugin); Assert.IsInstanceOf(plugin.RibbonCommandHandler); } } [Test] public void GetPropertyInfos_ReturnsSupportedPropertyInfos() { // Setup using (var plugin = new MacroStabilityInwardsPlugin()) { // Call PropertyInfo[] propertyInfos = plugin.GetPropertyInfos().ToArray(); // Assert Assert.AreEqual(8, propertyInfos.Length); PluginTestHelper.AssertPropertyInfoDefined( propertyInfos, typeof(MacroStabilityInwardsFailureMechanismContext), typeof(MacroStabilityInwardsFailureMechanismContextProperties)); PluginTestHelper.AssertPropertyInfoDefined( propertyInfos, typeof(PipingInputContext), typeof(PipingInputContextProperties)); PluginTestHelper.AssertPropertyInfoDefined( propertyInfos, typeof(PipingOutputContext), typeof(PipingOutputContextProperties)); PluginTestHelper.AssertPropertyInfoDefined( propertyInfos, typeof(RingtoetsPipingSurfaceLinesContext), typeof(RingtoetsPipingSurfaceLineCollectionProperties)); PluginTestHelper.AssertPropertyInfoDefined( propertyInfos, typeof(RingtoetsPipingSurfaceLine), typeof(RingtoetsPipingSurfaceLineProperties)); PluginTestHelper.AssertPropertyInfoDefined( propertyInfos, typeof(StochasticSoilModelCollectionContext), typeof(StochasticSoilModelCollectionProperties)); PluginTestHelper.AssertPropertyInfoDefined( propertyInfos, typeof(StochasticSoilModel), typeof(StochasticSoilModelProperties)); PluginTestHelper.AssertPropertyInfoDefined( propertyInfos, typeof(StochasticSoilProfile), typeof(StochasticSoilProfileProperties)); } } [Test] public void GetTreeNodeInfos_ReturnsSupportedTreeNodeInfos() { // Setup using (var plugin = new MacroStabilityInwardsPlugin()) { // Call TreeNodeInfo[] treeNodeInfos = plugin.GetTreeNodeInfos().ToArray(); // Assert Assert.AreEqual(13, treeNodeInfos.Length); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(RingtoetsPipingSurfaceLinesContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(RingtoetsPipingSurfaceLine))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(StochasticSoilModelCollectionContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(StochasticSoilModel))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(StochasticSoilProfile))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(PipingCalculationScenarioContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(PipingCalculationGroupContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(PipingInputContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(MacroStabilityInwardsFailureMechanismContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(FailureMechanismSectionResultContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(PipingOutputContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(PipingScenariosContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(EmptyPipingOutput))); } } [Test] public void GetViewInfos_ReturnsSupportedViewInfos() { // Setup using (var plugin = new MacroStabilityInwardsPlugin()) { // Call ViewInfo[] viewInfos = plugin.GetViewInfos().ToArray(); // Assert Assert.AreEqual(5, viewInfos.Length); Assert.IsTrue(viewInfos.Any(vi => vi.ViewType == typeof(MacroStabilityInwardsFailureMechanismView))); Assert.IsTrue(viewInfos.Any(vi => vi.ViewType == typeof(PipingCalculationsView))); Assert.IsTrue(viewInfos.Any(vi => vi.ViewType == typeof(PipingFailureMechanismResultView))); Assert.IsTrue(viewInfos.Any(vi => vi.ViewType == typeof(PipingInputView))); Assert.IsTrue(viewInfos.Any(vi => vi.ViewType == typeof(PipingScenariosView))); } } [Test] public void GetUpdateInfos_ReturnsSupportedUpdateInfos() { // Setup using (var plugin = new MacroStabilityInwardsPlugin()) { // Call UpdateInfo[] updateInfos = plugin.GetUpdateInfos().ToArray(); // Assert Assert.AreEqual(2, updateInfos.Length); Assert.AreEqual(1, updateInfos.Count(updateInfo => updateInfo.DataType == typeof(RingtoetsPipingSurfaceLinesContext))); Assert.AreEqual(1, updateInfos.Count(updateInfo => updateInfo.DataType == typeof(StochasticSoilModelCollectionContext))); } } [Test] public void GetImportInfos_ReturnsSupportedImportInfos() { // Setup using (var plugin = new MacroStabilityInwardsPlugin()) { // Call ImportInfo[] importInfos = plugin.GetImportInfos().ToArray(); // Assert Assert.AreEqual(3, importInfos.Length); Assert.IsTrue(importInfos.Any(i => i.DataType == typeof(RingtoetsPipingSurfaceLinesContext))); Assert.IsTrue(importInfos.Any(i => i.DataType == typeof(StochasticSoilModelCollectionContext))); Assert.IsTrue(importInfos.Any(i => i.DataType == typeof(PipingCalculationGroupContext))); } } [Test] public void GetExportInfos_ReturnsSupportedExportInfos() { // Setup using (var plugin = new MacroStabilityInwardsPlugin()) { // Call ExportInfo[] exportInfos = plugin.GetExportInfos().ToArray(); // Assert Assert.AreEqual(2, exportInfos.Length); Assert.IsTrue(exportInfos.Any(tni => tni.DataType == typeof(PipingCalculationGroupContext))); Assert.IsTrue(exportInfos.Any(tni => tni.DataType == typeof(PipingCalculationScenarioContext))); } } } }