Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/Ringtoets.Common.IO.Test.csproj =================================================================== diff -u -r0b9d2e855b0a0471854910ec1f2a237b65aac8f0 -r80f04760977eeb1f2f2781ff9600ffa4d51b7060 --- Ringtoets/Common/test/Ringtoets.Common.IO.Test/Ringtoets.Common.IO.Test.csproj (.../Ringtoets.Common.IO.Test.csproj) (revision 0b9d2e855b0a0471854910ec1f2a237b65aac8f0) +++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/Ringtoets.Common.IO.Test.csproj (.../Ringtoets.Common.IO.Test.csproj) (revision 80f04760977eeb1f2f2781ff9600ffa4d51b7060) @@ -119,7 +119,7 @@ - + Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/SoilLayer2DGeometryReaderTest.cs =================================================================== diff -u -r0b9d2e855b0a0471854910ec1f2a237b65aac8f0 -r80f04760977eeb1f2f2781ff9600ffa4d51b7060 --- Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/SoilLayer2DGeometryReaderTest.cs (.../SoilLayer2DGeometryReaderTest.cs) (revision 0b9d2e855b0a0471854910ec1f2a237b65aac8f0) +++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/SoilLayer2DGeometryReaderTest.cs (.../SoilLayer2DGeometryReaderTest.cs) (revision 80f04760977eeb1f2f2781ff9600ffa4d51b7060) @@ -203,14 +203,10 @@ double y1 = random.NextDouble(); double y2 = random.NextDouble(); - string x1String = x1.ToString(invariantCulture); - string x2String = x2.ToString(invariantCulture); - string y1String = y1.ToString(invariantCulture); - string y2String = y2.ToString(invariantCulture); - double parsedX1 = double.Parse(x1String, invariantCulture); - double parsedX2 = double.Parse(x2String, invariantCulture); - double parsedY1 = double.Parse(y1String, invariantCulture); - double parsedY2 = double.Parse(y2String, invariantCulture); + string x1String = XmlConvert.ToString(x1); + string x2String = XmlConvert.ToString(x2); + string y1String = XmlConvert.ToString(y1); + string y2String = XmlConvert.ToString(y2); XDocument xmlDoc = GetXmlDocument( string.Format(invariantCulture, "" + @@ -228,7 +224,8 @@ // Assert Assert.NotNull(result); - var expectedSegment = new Segment2D(new Point2D(parsedX1, parsedY1), new Point2D(parsedX2, parsedY2)); + + var expectedSegment = new Segment2D(new Point2D(x1, y1), new Point2D(x2, y2)); var expectedCollection = new[] { new List @@ -309,14 +306,10 @@ double y1 = random.NextDouble(); double y2 = random.NextDouble(); - string x1String = x1.ToString(invariantCulture); - string x2String = x2.ToString(invariantCulture); - string y1String = y1.ToString(invariantCulture); - string y2String = y2.ToString(invariantCulture); - double parsedX1 = XmlConvert.ToDouble(x1String); - double parsedX2 = XmlConvert.ToDouble(x2String); - double parsedY1 = XmlConvert.ToDouble(y1String); - double parsedY2 = XmlConvert.ToDouble(y2String); + string x1String = XmlConvert.ToString(x1); + string x2String = XmlConvert.ToString(x2); + string y1String = XmlConvert.ToString(y1); + string y2String = XmlConvert.ToString(y2); XDocument bytes = GetXmlDocument( string.Format(invariantCulture, "" + @@ -335,7 +328,7 @@ // Assert Assert.NotNull(result); - var expectedSegment = new Segment2D(new Point2D(parsedX1, parsedY1), new Point2D(parsedX2, parsedY2)); + var expectedSegment = new Segment2D(new Point2D(x1, y1), new Point2D(x2, y2)); CollectionAssert.AreEqual(new List { expectedSegment, @@ -344,21 +337,21 @@ } /// - /// Takes a which describes an XML document and returns + /// Takes a which describes an XML document and returns /// an from this. /// - /// The to convert to an . - /// The constructed from . - /// Thrown when is null. - /// Thrown when does not describe + /// The to convert to an . + /// The constructed from . + /// Thrown when is null. + /// Thrown when does not describe /// a valid XML document. - private static XDocument GetXmlDocument(string str) + private static XDocument GetXmlDocument(string xmlString) { - return XDocument.Load(new MemoryStream(GetByteArray(str))); + return XDocument.Load(new MemoryStream(GetByteArray(xmlString))); } /// - /// Takes a and returns an of , + /// Takes a and returns an of /// which contains the same information as the original . /// /// The to convert to an of Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/SoilLayer2DTest.cs =================================================================== diff -u -re00c710f89f381dd32218997530690b900f349cc -r80f04760977eeb1f2f2781ff9600ffa4d51b7060 --- Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/SoilLayer2DTest.cs (.../SoilLayer2DTest.cs) (revision e00c710f89f381dd32218997530690b900f349cc) +++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/SoilLayer2DTest.cs (.../SoilLayer2DTest.cs) (revision 80f04760977eeb1f2f2781ff9600ffa4d51b7060) @@ -21,7 +21,6 @@ using System; using System.Collections.Generic; -using System.Drawing; using System.Linq; using Core.Common.Base.Geometry; using NUnit.Framework; @@ -33,33 +32,13 @@ public class SoilLayer2DTest { [Test] - public void DefaultConstructor_NotInstantiatedOuterLoopAndEmptyInnerLoops() + public void DefaultConstructor_ExpectedPropertiesSet() { // Call var layer = new SoilLayer2D(); // Assert Assert.IsInstanceOf(layer); - Assert.IsFalse(layer.IsAquifer); - Assert.IsEmpty(layer.MaterialName); - Assert.AreEqual(Color.Empty, layer.Color); - Assert.IsNull(layer.OuterLoop); - CollectionAssert.IsEmpty(layer.InnerLoops); - - Assert.IsNull(layer.BelowPhreaticLevelDistribution); - Assert.IsNaN(layer.BelowPhreaticLevelShift); - Assert.IsNaN(layer.BelowPhreaticLevelMean); - Assert.IsNaN(layer.BelowPhreaticLevelDeviation); - - Assert.IsNull(layer.DiameterD70Distribution); - Assert.IsNaN(layer.DiameterD70Shift); - Assert.IsNaN(layer.DiameterD70Mean); - Assert.IsNaN(layer.DiameterD70CoefficientOfVariation); - - Assert.IsNull(layer.PermeabilityDistribution); - Assert.IsNaN(layer.PermeabilityShift); - Assert.IsNaN(layer.PermeabilityMean); - Assert.IsNaN(layer.PermeabilityCoefficientOfVariation); } [Test] Fisheye: Tag 80f04760977eeb1f2f2781ff9600ffa4d51b7060 refers to a dead (removed) revision in file `Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/SoilLayerColorConverter.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/SoilLayerColorConverterTest.cs =================================================================== diff -u --- Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/SoilLayerColorConverterTest.cs (revision 0) +++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/SoilLayerColorConverterTest.cs (revision 80f04760977eeb1f2f2781ff9600ffa4d51b7060) @@ -0,0 +1,64 @@ +// 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.Drawing; +using NUnit.Framework; +using Ringtoets.Common.IO.SoilProfile; + +namespace Ringtoets.Common.IO.Test.SoilProfile +{ + [TestFixture] + public class SoilLayerColorConverterTest + { + [Test] + public void Convert_Null_ReturnsEmptyColor() + { + // Call + Color color = SoilLayerColorConverter.Convert(null); + + // Assert + Assert.AreEqual(Color.Empty, color); + } + + [Test] + [TestCase(-12156236, 70, 130, 180)] + [TestCase(-8372160, 128, 64, 64)] + [TestCase(-65536, 255, 0, 0)] + [TestCase(-14634326, 32, 178, 170)] + [TestCase(-6632142, 154, 205, 50)] + [TestCase(-12566528, 64, 64, 0)] + [TestCase(-7278960, 144, 238, 144)] + [TestCase(-8323200, 128, 255, 128)] + [TestCase(-65281, 255, 0, 255)] + [TestCase(-8372224, 128, 64, 0)] + public void Convert_DifferentDoubleValues_ReturnsExpectedColor(double colorValue, int r, int g, int b) + { + // Call + Color color = SoilLayerColorConverter.Convert(colorValue); + + // Assert + Assert.AreEqual(r, color.R); + Assert.AreEqual(g, color.G); + Assert.AreEqual(b, color.B); + Assert.AreEqual(255, color.A); + } + } +} \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/SoilProfile1DReaderTest.cs =================================================================== diff -u -r28064349855037e892288c81383f1413f4e84f4c -r80f04760977eeb1f2f2781ff9600ffa4d51b7060 --- Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/SoilProfile1DReaderTest.cs (.../SoilProfile1DReaderTest.cs) (revision 28064349855037e892288c81383f1413f4e84f4c) +++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/SoilProfile1DReaderTest.cs (.../SoilProfile1DReaderTest.cs) (revision 80f04760977eeb1f2f2781ff9600ffa4d51b7060) @@ -59,7 +59,7 @@ [Test] [TestCaseSource(typeof(InvalidPathHelper), nameof(InvalidPathHelper.InvalidPaths))] - public void Constructor_FileNullOrEmpty_ThrowsCriticalFileReadException(string fileName) + public void Constructor_InvalidPath_ThrowsCriticalFileReadException(string fileName) { // Call TestDelegate test = () => Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/SoilProfile1DTest.cs =================================================================== diff -u -r0321f85aefaf574d1c4005329a5034c1b34ba4d2 -r80f04760977eeb1f2f2781ff9600ffa4d51b7060 --- Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/SoilProfile1DTest.cs (.../SoilProfile1DTest.cs) (revision 0321f85aefaf574d1c4005329a5034c1b34ba4d2) +++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/SoilProfile1DTest.cs (.../SoilProfile1DTest.cs) (revision 80f04760977eeb1f2f2781ff9600ffa4d51b7060) @@ -103,6 +103,7 @@ Assert.AreEqual(name, soilProfile1D.Name); Assert.AreEqual(bottom, soilProfile1D.Bottom); CollectionAssert.AreEqual(soilLayer1Ds, soilProfile1D.Layers); + Assert.AreNotSame(soilLayer1Ds, soilProfile1D.Layers); } } } \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/SoilProfile2DReaderTest.cs =================================================================== diff -u -r28064349855037e892288c81383f1413f4e84f4c -r80f04760977eeb1f2f2781ff9600ffa4d51b7060 --- Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/SoilProfile2DReaderTest.cs (.../SoilProfile2DReaderTest.cs) (revision 28064349855037e892288c81383f1413f4e84f4c) +++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/SoilProfile2DReaderTest.cs (.../SoilProfile2DReaderTest.cs) (revision 80f04760977eeb1f2f2781ff9600ffa4d51b7060) @@ -22,6 +22,7 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.Drawing; using System.IO; using System.Linq; using Core.Common.Base.IO; @@ -59,7 +60,7 @@ [Test] [TestCaseSource(typeof(InvalidPathHelper), nameof(InvalidPathHelper.InvalidPaths))] - public void Constructor_FileNullOrEmpty_ThrowsCriticalFileReadException(string fileName) + public void Constructor_InvalidPath_ThrowsCriticalFileReadException(string fileName) { // Call TestDelegate test = () => @@ -136,6 +137,64 @@ Assert.AreEqual("Profile", soilProfile2D.Name); Assert.AreEqual(85.2, soilProfile2D.IntersectionX); Assert.AreEqual(3, soilProfile2D.Layers.Count()); + + CollectionAssert.AreEqual(new[] + { + true, + false, + false + }, soilProfile2D.Layers.Select(l => l.IsAquifer)); + CollectionAssert.AreEqual(new[] + { + Color.FromArgb(70, 130, 180), + Color.FromArgb(255, 0, 0), + Color.FromArgb(128, 255, 128) + }, soilProfile2D.Layers.Select(l => l.Color)); + CollectionAssert.AreEqual(new[] + { + 0.21, + 0.71, + 3.88 + }, soilProfile2D.Layers.Select(l => l.BelowPhreaticLevelMean)); + CollectionAssert.AreEqual(new[] + { + 0.001, + 0.02, + 0.08 + }, soilProfile2D.Layers.Select(l => l.BelowPhreaticLevelDeviation)); + CollectionAssert.AreEqual(new[] + { + 0.3, + 0.32, + 0.4 + }, soilProfile2D.Layers.Select(l => l.BelowPhreaticLevelShift)); + CollectionAssert.AreEqual(new[] + { + 0.51, + 0.01, + 11.3 + }, soilProfile2D.Layers.Select(l => l.DiameterD70Mean)); + CollectionAssert.AreEqual(new[] + { + 0.029411, + 0.1, + 0.017699 + }, soilProfile2D.Layers.Select(l => l.DiameterD70CoefficientOfVariation)); + CollectionAssert.AreEqual(new[] + { + 1.01, + 9.99, + 5.21 + }, soilProfile2D.Layers.Select(l => l.PermeabilityMean)); + CollectionAssert.AreEqual(new[] + { + 0.024752, + + 0.01001, + 0.057582 + }, soilProfile2D.Layers.Select(l => l.PermeabilityCoefficientOfVariation)); + + Assert.IsTrue(TestHelper.CanOpenFileForWrite(dbFile)); } [Test] Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/SoilProfile2DTest.cs =================================================================== diff -u -r0321f85aefaf574d1c4005329a5034c1b34ba4d2 -r80f04760977eeb1f2f2781ff9600ffa4d51b7060 --- Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/SoilProfile2DTest.cs (.../SoilProfile2DTest.cs) (revision 0321f85aefaf574d1c4005329a5034c1b34ba4d2) +++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/SoilProfile2DTest.cs (.../SoilProfile2DTest.cs) (revision 80f04760977eeb1f2f2781ff9600ffa4d51b7060) @@ -86,6 +86,7 @@ Assert.AreEqual(id, soilProfile2D.Id); Assert.AreEqual(name, soilProfile2D.Name); CollectionAssert.AreEqual(soilLayer2Ds, soilProfile2D.Layers); + Assert.AreNotSame(soilLayer2Ds, soilProfile2D.Layers); Assert.IsNaN(soilProfile2D.IntersectionX); } } Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/StochasticSoilModelReaderTest.cs =================================================================== diff -u -r2dc7bb7aef782fd08d2474e14cc5486725896b38 -r80f04760977eeb1f2f2781ff9600ffa4d51b7060 --- Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/StochasticSoilModelReaderTest.cs (.../StochasticSoilModelReaderTest.cs) (revision 2dc7bb7aef782fd08d2474e14cc5486725896b38) +++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/StochasticSoilModelReaderTest.cs (.../StochasticSoilModelReaderTest.cs) (revision 80f04760977eeb1f2f2781ff9600ffa4d51b7060) @@ -59,7 +59,7 @@ [Test] [TestCaseSource(typeof(InvalidPathHelper), nameof(InvalidPathHelper.InvalidPaths))] - public void Constructor_FileNullOrEmpty_ThrowsCriticalFileReadException(string fileName) + public void Constructor_InvalidPath_ThrowsCriticalFileReadException(string fileName) { // Call TestDelegate test = () => @@ -311,7 +311,7 @@ } [Test] - public void ReadStochasticSoilModel_SoilModelWithoutStochasticSoilProfile_ThrowsStochasticSoilModelExceptionAndHasNext() + public void ReadStochasticSoilModel_SoilModelWithoutStochasticSoilProfile_ThrowsStochasticSoilModelExceptionAndCanContinueReading() { // Setup string dbFile = Path.Combine(testDataPath, "modelWithoutProfile.soil"); Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/StochasticSoilModelTest.cs =================================================================== diff -u -rbe4427a66ef77dfa213048b0a823824ea679bce3 -r80f04760977eeb1f2f2781ff9600ffa4d51b7060 --- Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/StochasticSoilModelTest.cs (.../StochasticSoilModelTest.cs) (revision be4427a66ef77dfa213048b0a823824ea679bce3) +++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/StochasticSoilModelTest.cs (.../StochasticSoilModelTest.cs) (revision 80f04760977eeb1f2f2781ff9600ffa4d51b7060) @@ -31,7 +31,7 @@ public class StochasticSoilModelTest { [Test] - public void Constructor_NameNull_ExpectedValues() + public void Constructor_NameNull_ThrowsArgumentNullException() { // Setup var failureMechanismType = new Random(145).NextEnumValue();