// 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 System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
using Ringtoets.Common.Data.AssessmentSection;
using Ringtoets.Common.Data.FailureMechanism;
using Ringtoets.Common.Data.Hydraulics;
using Ringtoets.Common.Data.TestUtil;
using Ringtoets.Revetment.Data;
using Ringtoets.Revetment.Data.TestUtil;
using Ringtoets.Revetment.IO.WaveConditions;
namespace Ringtoets.Revetment.IO.Test.WaveConditions
{
[TestFixture]
public class ExportableWaveConditionsFactoryTest
{
private static readonly TestWaveConditionsOutput waveConditionsOutput = new TestWaveConditionsOutput();
private readonly WaveConditionsOutput[] waveConditionsOutputCollection =
{
waveConditionsOutput
};
[Test]
public void CreateExportableWaveConditionsCollection_NameNull_ThrowArgumentNullException()
{
// Call
TestDelegate call = () => ExportableWaveConditionsFactory.CreateExportableWaveConditionsCollection(null,
new AssessmentSectionCategoryWaveConditionsInput(),
waveConditionsOutputCollection,
waveConditionsOutputCollection);
// Assert
var exception = Assert.Throws(call);
Assert.AreEqual("name", exception.ParamName);
}
[Test]
public void CreateExportableWaveConditionsCollection_WaveConditionsInputNull_ThrowArgumentNullException()
{
// Call
TestDelegate call = () => ExportableWaveConditionsFactory.CreateExportableWaveConditionsCollection("aName",
null,
waveConditionsOutputCollection,
waveConditionsOutputCollection);
// Assert
var exception = Assert.Throws(call);
Assert.AreEqual("waveConditionsInput", exception.ParamName);
}
[Test]
public void CreateExportableWaveConditionsCollection_ColumnsOutputNull_ThrowArgumentNullException()
{
// Call
TestDelegate call = () => ExportableWaveConditionsFactory.CreateExportableWaveConditionsCollection("aName",
new AssessmentSectionCategoryWaveConditionsInput(),
null,
waveConditionsOutputCollection);
// Assert
var exception = Assert.Throws(call);
Assert.AreEqual("columnsOutput", exception.ParamName);
}
[Test]
public void CreateExportableWaveConditionsCollection_BlocksOutputNull_ThrowArgumentNullException()
{
// Call
TestDelegate call = () => ExportableWaveConditionsFactory.CreateExportableWaveConditionsCollection("aName",
new AssessmentSectionCategoryWaveConditionsInput(),
waveConditionsOutputCollection,
null);
// Assert
var exception = Assert.Throws(call);
Assert.AreEqual("blocksOutput", exception.ParamName);
}
[Test]
public void CreateExportableWaveConditionsCollection_DataEmpty_ReturnsEmptyCollection()
{
// Call
IEnumerable exportableWaveConditionsCollection =
ExportableWaveConditionsFactory.CreateExportableWaveConditionsCollection("aName",
new AssessmentSectionCategoryWaveConditionsInput(),
Enumerable.Empty(),
Enumerable.Empty());
// Assert
CollectionAssert.IsEmpty(exportableWaveConditionsCollection);
}
[Test]
public void CreateExportableWaveConditionsCollection_ValidData_ReturnsValidCollection()
{
// Setup
var waveConditionsInput = new AssessmentSectionCategoryWaveConditionsInput
{
HydraulicBoundaryLocation = new HydraulicBoundaryLocation(0, "hblName", 1.0, 8.0),
ForeshoreProfile = new TestForeshoreProfile(),
UseForeshore = true,
CategoryType = AssessmentSectionCategoryType.SignalingNorm
};
// Call
ExportableWaveConditions[] exportableWaveConditionsCollection =
ExportableWaveConditionsFactory.CreateExportableWaveConditionsCollection("ewcName",
waveConditionsInput,
waveConditionsOutputCollection,
waveConditionsOutputCollection).ToArray();
// Assert
Assert.AreEqual(2, exportableWaveConditionsCollection.Length);
Assert.AreEqual(1, exportableWaveConditionsCollection.Count(e => e.CoverType == CoverType.StoneCoverColumns));
Assert.AreEqual(1, exportableWaveConditionsCollection.Count(e => e.CoverType == CoverType.StoneCoverBlocks));
ExportableWaveConditions exportableWaveConditions = exportableWaveConditionsCollection[0];
Assert.AreEqual("ewcName", exportableWaveConditions.CalculationName);
Assert.AreEqual("hblName", exportableWaveConditions.LocationName);
Assert.AreEqual(1.0, exportableWaveConditions.LocationXCoordinate);
Assert.AreEqual(8.0, exportableWaveConditions.LocationYCoordinate);
Assert.AreEqual("id", exportableWaveConditions.ForeshoreId);
Assert.AreEqual(false, exportableWaveConditions.UseBreakWater);
Assert.AreEqual(true, exportableWaveConditions.UseForeshore);
Assert.AreEqual(CoverType.StoneCoverColumns, exportableWaveConditions.CoverType);
Assert.AreEqual("Categoriegrens A", exportableWaveConditions.CategoryBoundaryName);
Assert.AreEqual(2, exportableWaveConditions.WaterLevel.NumberOfDecimalPlaces);
Assert.AreEqual(2, exportableWaveConditions.WaveHeight.NumberOfDecimalPlaces);
Assert.AreEqual(2, exportableWaveConditions.WavePeriod.NumberOfDecimalPlaces);
Assert.AreEqual(2, exportableWaveConditions.WaveAngle.NumberOfDecimalPlaces);
Assert.AreEqual(waveConditionsOutput.WaterLevel, exportableWaveConditions.WaterLevel);
Assert.AreEqual(waveConditionsOutput.WaveHeight, exportableWaveConditions.WaveHeight);
Assert.AreEqual(waveConditionsOutput.WavePeakPeriod, exportableWaveConditions.WavePeriod);
Assert.AreEqual(waveConditionsOutput.WaveAngle, exportableWaveConditions.WaveAngle);
Assert.AreEqual(waveConditionsOutput.WaveDirection, exportableWaveConditions.WaveDirection);
}
[Test]
public void CreateExportableWaveConditionsCollectionWithFailureMechanismCategoryWaveConditionsInput_NameNull_ThrowArgumentNullException()
{
// Call
TestDelegate call = () => ExportableWaveConditionsFactory.CreateExportableWaveConditionsCollection(null,
new FailureMechanismCategoryWaveConditionsInput(),
waveConditionsOutputCollection);
// Assert
var exception = Assert.Throws(call);
Assert.AreEqual("name", exception.ParamName);
}
[Test]
public void CreateExportableWaveConditionsCollectionWithFailureMechanismCategoryWaveConditionsInput_WaveConditionsInputNull_ThrowArgumentNullException()
{
// Call
TestDelegate call = () => ExportableWaveConditionsFactory.CreateExportableWaveConditionsCollection("aName",
(FailureMechanismCategoryWaveConditionsInput) null,
waveConditionsOutputCollection);
// Assert
var exception = Assert.Throws(call);
Assert.AreEqual("waveConditionsInput", exception.ParamName);
}
[Test]
public void CreateExportableWaveConditionsCollectionWithFailureMechanismCategoryWaveConditionsInput_OutputNull_ThrowArgumentNullException()
{
// Call
TestDelegate call = () => ExportableWaveConditionsFactory.CreateExportableWaveConditionsCollection("aName",
new FailureMechanismCategoryWaveConditionsInput(),
null);
// Assert
var exception = Assert.Throws(call);
Assert.AreEqual("output", exception.ParamName);
}
[Test]
public void CreateExportableWaveConditionsCollectionWithFailureMechanismCategoryWaveConditionsInput_ValidDataWithCoverType_ReturnsValidCollection()
{
// Setup
var waveConditionsInput = new FailureMechanismCategoryWaveConditionsInput
{
HydraulicBoundaryLocation = new HydraulicBoundaryLocation(0, "hblName", 1.0, 8.0),
ForeshoreProfile = new TestForeshoreProfile(),
UseForeshore = true,
CategoryType = FailureMechanismCategoryType.MechanismSpecificFactorizedSignalingNorm
};
// Call
ExportableWaveConditions[] exportableWaveConditionsCollection =
ExportableWaveConditionsFactory.CreateExportableWaveConditionsCollection("ewcName",
waveConditionsInput,
waveConditionsOutputCollection).ToArray();
// Assert
Assert.AreEqual(1, exportableWaveConditionsCollection.Length);
ExportableWaveConditions exportableWaveConditions = exportableWaveConditionsCollection[0];
Assert.AreEqual("ewcName", exportableWaveConditions.CalculationName);
Assert.AreEqual("hblName", exportableWaveConditions.LocationName);
Assert.AreEqual(1.0, exportableWaveConditions.LocationXCoordinate);
Assert.AreEqual(8.0, exportableWaveConditions.LocationYCoordinate);
Assert.AreEqual("id", exportableWaveConditions.ForeshoreId);
Assert.AreEqual(false, exportableWaveConditions.UseBreakWater);
Assert.AreEqual(true, exportableWaveConditions.UseForeshore);
Assert.AreEqual(CoverType.Grass, exportableWaveConditions.CoverType);
Assert.AreEqual("Iv->IIv", exportableWaveConditions.CategoryBoundaryName);
Assert.AreEqual(2, exportableWaveConditions.WaterLevel.NumberOfDecimalPlaces);
Assert.AreEqual(2, exportableWaveConditions.WaveHeight.NumberOfDecimalPlaces);
Assert.AreEqual(2, exportableWaveConditions.WavePeriod.NumberOfDecimalPlaces);
Assert.AreEqual(2, exportableWaveConditions.WaveAngle.NumberOfDecimalPlaces);
Assert.AreEqual(waveConditionsOutput.WaterLevel, exportableWaveConditions.WaterLevel);
Assert.AreEqual(waveConditionsOutput.WaveHeight, exportableWaveConditions.WaveHeight);
Assert.AreEqual(waveConditionsOutput.WavePeakPeriod, exportableWaveConditions.WavePeriod);
Assert.AreEqual(waveConditionsOutput.WaveAngle, exportableWaveConditions.WaveAngle);
Assert.AreEqual(waveConditionsOutput.WaveDirection, exportableWaveConditions.WaveDirection);
}
[Test]
public void CreateExportableWaveConditionsCollectionWithAssessmentSectionCategoryWaveConditionsInput_NameNull_ThrowArgumentNullException()
{
// Call
TestDelegate call = () => ExportableWaveConditionsFactory.CreateExportableWaveConditionsCollection(null,
new AssessmentSectionCategoryWaveConditionsInput(),
waveConditionsOutputCollection);
// Assert
var exception = Assert.Throws(call);
Assert.AreEqual("name", exception.ParamName);
}
[Test]
public void CreateExportableWaveConditionsCollectionWithAssessmentSectionCategoryWaveConditionsInput_WaveConditionsInputNull_ThrowArgumentNullException()
{
// Call
TestDelegate call = () => ExportableWaveConditionsFactory.CreateExportableWaveConditionsCollection("aName",
(AssessmentSectionCategoryWaveConditionsInput) null,
waveConditionsOutputCollection);
// Assert
var exception = Assert.Throws(call);
Assert.AreEqual("waveConditionsInput", exception.ParamName);
}
[Test]
public void CreateExportableWaveConditionsCollectionWithAssessmentSectionCategoryWaveConditionsInput_OutputNull_ThrowArgumentNullException()
{
// Call
TestDelegate call = () => ExportableWaveConditionsFactory.CreateExportableWaveConditionsCollection("aName",
new AssessmentSectionCategoryWaveConditionsInput(),
null);
// Assert
var exception = Assert.Throws(call);
Assert.AreEqual("output", exception.ParamName);
}
[Test]
public void CreateExportableWaveConditionsCollectionWithAssessmentSectionCategoryWaveConditionsInput_ValidDataWithCoverType_ReturnsValidCollection()
{
// Setup
var waveConditionsInput = new AssessmentSectionCategoryWaveConditionsInput
{
HydraulicBoundaryLocation = new HydraulicBoundaryLocation(0, "hblName", 1.0, 8.0),
ForeshoreProfile = new TestForeshoreProfile(),
UseForeshore = true,
CategoryType = AssessmentSectionCategoryType.LowerLimitNorm
};
// Call
ExportableWaveConditions[] exportableWaveConditionsCollection =
ExportableWaveConditionsFactory.CreateExportableWaveConditionsCollection("ewcName",
waveConditionsInput,
waveConditionsOutputCollection).ToArray();
// Assert
Assert.AreEqual(1, exportableWaveConditionsCollection.Length);
ExportableWaveConditions exportableWaveConditions = exportableWaveConditionsCollection[0];
Assert.AreEqual("ewcName", exportableWaveConditions.CalculationName);
Assert.AreEqual("hblName", exportableWaveConditions.LocationName);
Assert.AreEqual(1.0, exportableWaveConditions.LocationXCoordinate);
Assert.AreEqual(8.0, exportableWaveConditions.LocationYCoordinate);
Assert.AreEqual("id", exportableWaveConditions.ForeshoreId);
Assert.AreEqual(false, exportableWaveConditions.UseBreakWater);
Assert.AreEqual(true, exportableWaveConditions.UseForeshore);
Assert.AreEqual(CoverType.Asphalt, exportableWaveConditions.CoverType);
Assert.AreEqual("Categoriegrens B", exportableWaveConditions.CategoryBoundaryName);
Assert.AreEqual(2, exportableWaveConditions.WaterLevel.NumberOfDecimalPlaces);
Assert.AreEqual(2, exportableWaveConditions.WaveHeight.NumberOfDecimalPlaces);
Assert.AreEqual(2, exportableWaveConditions.WavePeriod.NumberOfDecimalPlaces);
Assert.AreEqual(2, exportableWaveConditions.WaveAngle.NumberOfDecimalPlaces);
Assert.AreEqual(waveConditionsOutput.WaterLevel, exportableWaveConditions.WaterLevel);
Assert.AreEqual(waveConditionsOutput.WaveHeight, exportableWaveConditions.WaveHeight);
Assert.AreEqual(waveConditionsOutput.WavePeakPeriod, exportableWaveConditions.WavePeriod);
Assert.AreEqual(waveConditionsOutput.WaveAngle, exportableWaveConditions.WaveAngle);
Assert.AreEqual(waveConditionsOutput.WaveDirection, exportableWaveConditions.WaveDirection);
}
}
}