// 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.Collections.Generic;
using System.Linq;
using System.Threading;
using Core.Common.Base;
using Core.Common.Controls.TreeView;
using Core.Common.Gui.Plugin;
using Core.Common.Gui.TestUtil;
using NUnit.Framework;
using Ringtoets.Common.Data.Calculation;
using Ringtoets.Common.Data.FailureMechanism;
using Ringtoets.Common.Forms.PresentationObjects;
using Ringtoets.Common.Forms.PropertyClasses;
using Ringtoets.Common.Forms.Views;
using Ringtoets.Piping.Data;
using Ringtoets.Piping.Data.SoilProfile;
using Ringtoets.Piping.Forms.PresentationObjects;
using Ringtoets.Piping.Forms.PropertyClasses;
using Ringtoets.Piping.Forms.Views;
using Ringtoets.Piping.Primitives;
namespace Ringtoets.Piping.Plugin.Test
{
[TestFixture]
public class PipingPluginTest
{
[Test]
[Apartment(ApartmentState.STA)]
public void DefaultConstructor_ExpectedValues()
{
// Call
using (var plugin = new PipingPlugin())
{
// Assert
Assert.IsInstanceOf(plugin);
}
}
[Test]
public void GetPropertyInfos_ReturnsSupportedPropertyInfos()
{
// Setup
using (var plugin = new PipingPlugin())
{
// Call
PropertyInfo[] propertyInfos = plugin.GetPropertyInfos().ToArray();
// Assert
Assert.AreEqual(9, propertyInfos.Length);
PluginTestHelper.AssertPropertyInfoDefined(
propertyInfos,
typeof(PipingFailureMechanismContext),
typeof(PipingFailureMechanismProperties));
PluginTestHelper.AssertPropertyInfoDefined(
propertyInfos,
typeof(PipingInputContext),
typeof(PipingInputContextProperties));
PluginTestHelper.AssertPropertyInfoDefined(
propertyInfos,
typeof(PipingOutputContext),
typeof(PipingOutputProperties));
PluginTestHelper.AssertPropertyInfoDefined(
propertyInfos,
typeof(PipingSurfaceLinesContext),
typeof(PipingSurfaceLineCollectionProperties));
PluginTestHelper.AssertPropertyInfoDefined(
propertyInfos,
typeof(PipingSurfaceLine),
typeof(PipingSurfaceLineProperties));
PluginTestHelper.AssertPropertyInfoDefined(
propertyInfos,
typeof(PipingStochasticSoilModelCollectionContext),
typeof(PipingStochasticSoilModelCollectionProperties));
PluginTestHelper.AssertPropertyInfoDefined(
propertyInfos,
typeof(PipingStochasticSoilModel),
typeof(PipingStochasticSoilModelProperties));
PluginTestHelper.AssertPropertyInfoDefined(
propertyInfos,
typeof(PipingStochasticSoilProfile),
typeof(PipingStochasticSoilProfileProperties));
PluginTestHelper.AssertPropertyInfoDefined(
propertyInfos,
typeof(PipingFailureMechanismSectionsContext),
typeof(FailureMechanismSectionsProbabilityAssessmentProperties));
}
}
[Test]
public void GetTreeNodeInfos_ReturnsSupportedTreeNodeInfos()
{
// Setup
using (var plugin = new PipingPlugin())
{
// Call
TreeNodeInfo[] treeNodeInfos = plugin.GetTreeNodeInfos().ToArray();
// Assert
Assert.AreEqual(13, treeNodeInfos.Length);
Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(PipingSurfaceLinesContext)));
Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(PipingSurfaceLine)));
Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(PipingStochasticSoilModelCollectionContext)));
Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(PipingStochasticSoilModel)));
Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(PipingStochasticSoilProfile)));
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(PipingFailureMechanismContext)));
Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(ProbabilityFailureMechanismSectionResultContext)));
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 PipingPlugin())
{
// Call
ViewInfo[] viewInfos = plugin.GetViewInfos().ToArray();
// Assert
Assert.AreEqual(6, viewInfos.Length);
PluginTestHelper.AssertViewInfoDefined(
viewInfos,
typeof(PipingFailureMechanismContext),
typeof(PipingFailureMechanismView));
PluginTestHelper.AssertViewInfoDefined(
viewInfos,
typeof(ProbabilityFailureMechanismSectionResultContext),
typeof(IObservableEnumerable),
typeof(PipingFailureMechanismResultView));
PluginTestHelper.AssertViewInfoDefined(
viewInfos,
typeof(PipingCalculationGroupContext),
typeof(CalculationGroup),
typeof(PipingCalculationsView));
PluginTestHelper.AssertViewInfoDefined(
viewInfos,
typeof(PipingInputContext),
typeof(PipingCalculationScenario),
typeof(PipingInputView));
PluginTestHelper.AssertViewInfoDefined(
viewInfos,
typeof(PipingScenariosContext),
typeof(CalculationGroup),
typeof(PipingScenariosView));
PluginTestHelper.AssertViewInfoDefined(
viewInfos,
typeof(PipingFailureMechanismSectionsContext),
typeof(IEnumerable),
typeof(FailureMechanismSectionsProbabilityAssessmentView));
}
}
[Test]
public void GetUpdateInfos_ReturnsSupportedUpdateInfos()
{
// Setup
using (var plugin = new PipingPlugin())
{
// Call
UpdateInfo[] updateInfos = plugin.GetUpdateInfos().ToArray();
// Assert
Assert.AreEqual(2, updateInfos.Length);
Assert.AreEqual(1, updateInfos.Count(updateInfo => updateInfo.DataType == typeof(PipingSurfaceLinesContext)));
Assert.AreEqual(1, updateInfos.Count(updateInfo => updateInfo.DataType == typeof(PipingStochasticSoilModelCollectionContext)));
}
}
[Test]
public void GetImportInfos_ReturnsSupportedImportInfos()
{
// Setup
using (var plugin = new PipingPlugin())
{
// Call
ImportInfo[] importInfos = plugin.GetImportInfos().ToArray();
// Assert
Assert.AreEqual(3, importInfos.Length);
Assert.IsTrue(importInfos.Any(i => i.DataType == typeof(PipingSurfaceLinesContext)));
Assert.IsTrue(importInfos.Any(i => i.DataType == typeof(PipingStochasticSoilModelCollectionContext)));
Assert.IsTrue(importInfos.Any(i => i.DataType == typeof(PipingCalculationGroupContext)));
}
}
[Test]
public void GetExportInfos_ReturnsSupportedExportInfos()
{
// Setup
using (var plugin = new PipingPlugin())
{
// 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)));
}
}
}
}