// 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;
using Core.Common.Base;
using Core.Common.TestUtil;
using NUnit.Framework;
using Ringtoets.Common.Data.Calculation;
using Ringtoets.MacroStabilityInwards.Data.TestUtil;
namespace Ringtoets.MacroStabilityInwards.Data.Test
{
[TestFixture]
public class MacroStabilityInwardsOutputTest
{
[Test]
public void Constructor_SlidingCurveNull_ThrowsArgumentNullException()
{
// Setup
var slipPlane = new MacroStabilityInwardsSlipPlaneUpliftVan(MacroStabilityInwardsGridOutputTestFactory.Create(),
MacroStabilityInwardsGridOutputTestFactory.Create(),
new double[0]);
// Call
TestDelegate call = () => new MacroStabilityInwardsOutput(null, slipPlane, new MacroStabilityInwardsOutput.ConstructionProperties());
// Assert
var exception = Assert.Throws(call);
Assert.AreEqual("slidingCurve", exception.ParamName);
}
[Test]
public void Constructor_SlipPlaneNull_ThrowsArgumentNullException()
{
// Setup
var slidingCurve = new MacroStabilityInwardsSlidingCurve(MacroStabilityInwardsSlidingCircleTestFactory.Create(),
MacroStabilityInwardsSlidingCircleTestFactory.Create(),
new MacroStabilityInwardsSlice[0], 0, 0);
// Call
TestDelegate call = () => new MacroStabilityInwardsOutput(slidingCurve, null,
new MacroStabilityInwardsOutput.ConstructionProperties());
// Assert
var exception = Assert.Throws(call);
Assert.AreEqual("slipPlane", exception.ParamName);
}
[Test]
public void Constructor_ConstructionPropertiesNull_ThrowsArgumentNullException()
{
// Setup
var slidingCurve = new MacroStabilityInwardsSlidingCurve(MacroStabilityInwardsSlidingCircleTestFactory.Create(),
MacroStabilityInwardsSlidingCircleTestFactory.Create(),
new MacroStabilityInwardsSlice[0], 0, 0);
var slipPlane = new MacroStabilityInwardsSlipPlaneUpliftVan(MacroStabilityInwardsGridOutputTestFactory.Create(),
MacroStabilityInwardsGridOutputTestFactory.Create(),
new double[0]);
// Call
TestDelegate call = () => new MacroStabilityInwardsOutput(slidingCurve, slipPlane, null);
// Assert
var exception = Assert.Throws(call);
Assert.AreEqual("properties", exception.ParamName);
}
[Test]
public void Constructor_WithParameters_ExpectedValues()
{
// Setup
var slidingCurve = new MacroStabilityInwardsSlidingCurve(MacroStabilityInwardsSlidingCircleTestFactory.Create(),
MacroStabilityInwardsSlidingCircleTestFactory.Create(),
new MacroStabilityInwardsSlice[0], 0, 0);
var slipPlane = new MacroStabilityInwardsSlipPlaneUpliftVan(MacroStabilityInwardsGridOutputTestFactory.Create(),
MacroStabilityInwardsGridOutputTestFactory.Create(),
new double[0]);
// Call
var output = new MacroStabilityInwardsOutput(slidingCurve, slipPlane, new MacroStabilityInwardsOutput.ConstructionProperties());
// Assert
Assert.AreSame(slidingCurve, output.SlidingCurve);
Assert.AreSame(slipPlane, output.SlipPlane);
}
[Test]
public void Constructor_ConstructionPropertiesWithoutValuesSet_PropertiesAreDefault()
{
// Setup
var slidingCurve = new MacroStabilityInwardsSlidingCurve(MacroStabilityInwardsSlidingCircleTestFactory.Create(),
MacroStabilityInwardsSlidingCircleTestFactory.Create(),
new MacroStabilityInwardsSlice[0], 0, 0);
var slipPlane = new MacroStabilityInwardsSlipPlaneUpliftVan(MacroStabilityInwardsGridOutputTestFactory.Create(),
MacroStabilityInwardsGridOutputTestFactory.Create(),
new double[0]);
// Call
var output = new MacroStabilityInwardsOutput(slidingCurve, slipPlane, new MacroStabilityInwardsOutput.ConstructionProperties());
// Assert
Assert.IsNaN(output.FactorOfStability);
Assert.IsNaN(output.ZValue);
Assert.IsNaN(output.ForbiddenZonesXEntryMin);
Assert.IsNaN(output.ForbiddenZonesXEntryMax);
Assert.IsFalse(output.ForbiddenZonesAutomaticallyCalculated);
Assert.IsFalse(output.GridAutomaticallyCalculated);
}
[Test]
public void Constructor_ExpectedValues()
{
// Setup
var slidingCurve = new MacroStabilityInwardsSlidingCurve(MacroStabilityInwardsSlidingCircleTestFactory.Create(),
MacroStabilityInwardsSlidingCircleTestFactory.Create(),
new MacroStabilityInwardsSlice[0], 0, 0);
var slipPlane = new MacroStabilityInwardsSlipPlaneUpliftVan(MacroStabilityInwardsGridOutputTestFactory.Create(),
MacroStabilityInwardsGridOutputTestFactory.Create(),
new double[0]);
var random = new Random(21);
double factorOfStability = random.NextDouble();
double zValue = random.NextDouble();
double xEntryMin = random.NextDouble();
double xEntryMax = random.NextDouble();
bool forbiddenZonesAutomaticallyCalculated = random.NextBoolean();
bool gridAutomaticallyCalculated = random.NextBoolean();
var properties = new MacroStabilityInwardsOutput.ConstructionProperties
{
FactorOfStability = factorOfStability,
ZValue = zValue,
ForbiddenZonesXEntryMin = xEntryMin,
ForbiddenZonesXEntryMax = xEntryMax,
ForbiddenZonesAutomaticallyCalculated = forbiddenZonesAutomaticallyCalculated,
GridAutomaticallyCalculated = gridAutomaticallyCalculated
};
// Call
var output = new MacroStabilityInwardsOutput(slidingCurve, slipPlane, properties);
// Assert
Assert.IsInstanceOf(output);
Assert.IsInstanceOf(output);
Assert.AreEqual(factorOfStability, output.FactorOfStability);
Assert.AreEqual(zValue, output.ZValue);
Assert.AreEqual(xEntryMin, output.ForbiddenZonesXEntryMin);
Assert.AreEqual(xEntryMax, output.ForbiddenZonesXEntryMax);
Assert.AreEqual(forbiddenZonesAutomaticallyCalculated, output.ForbiddenZonesAutomaticallyCalculated);
Assert.AreEqual(gridAutomaticallyCalculated, output.GridAutomaticallyCalculated);
}
}
}