// 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 NUnit.Framework;
using Ringtoets.Common.IO.SoilProfile;
namespace Ringtoets.Common.IO.Test.SoilProfile
{
[TestFixture]
public class SoilProfile1DTest
{
[Test]
public void Constructor_NameNull_ThrowsArgumentNullException()
{
// Setup
var soilLayer1Ds = new[]
{
new SoilLayer1D(2)
};
// Call
TestDelegate test = () => new SoilProfile1D(1, null, 1, soilLayer1Ds);
// Assert
var exception = Assert.Throws(test);
Assert.AreEqual("name", exception.ParamName);
}
[Test]
public void Constructor_LayersNull_ThrowsArgumentNullException()
{
// Call
TestDelegate test = () => new SoilProfile1D(1, "name", 1, null);
// Assert
var exception = Assert.Throws(test);
Assert.AreEqual("layers", exception.ParamName);
}
[Test]
public void Constructor_NoLayers_ThrowsArgumentException()
{
// Call
TestDelegate test = () => new SoilProfile1D(1, "name", 1, new SoilLayer1D[0]);
// Assert
var exception = Assert.Throws(test);
Assert.AreEqual("Geen lagen gevonden voor de ondergrondschematisatie.", exception.Message);
}
[Test]
public void Constructor_BottomAboveLayers_ThrowsArgumentException()
{
// Call
TestDelegate test = () => new SoilProfile1D(1, "name", 9999, new[]
{
new SoilLayer1D(2)
});
// Assert
var exception = Assert.Throws(test);
Assert.AreEqual("Eén of meerdere lagen hebben een top onder de bodem van de ondergrondschematisatie.",
exception.Message);
}
[Test]
public void Constructor_ValidArguments_ReturnsExpectedProperties()
{
// Setup
const long id = 123;
const string name = "some name";
const int bottom = 1;
var soilLayer1Ds = new[]
{
new SoilLayer1D(2)
};
// Call
var soilProfile1D = new SoilProfile1D(id, name, bottom, soilLayer1Ds);
// Assert
Assert.IsInstanceOf(soilProfile1D);
Assert.AreEqual(id, soilProfile1D.Id);
Assert.AreEqual(name, soilProfile1D.Name);
Assert.AreEqual(bottom, soilProfile1D.Bottom);
CollectionAssert.AreEqual(soilLayer1Ds, soilProfile1D.Layers);
}
}
}