Index: Ringtoets/Common/src/Ringtoets.Common.IO/Ringtoets.Common.IO.csproj =================================================================== diff -u -r4e578730273a943bb02a2861c694a2707c8ef852 -r60bd3c063c8173f762c5762096efa38b87f780ed --- Ringtoets/Common/src/Ringtoets.Common.IO/Ringtoets.Common.IO.csproj (.../Ringtoets.Common.IO.csproj) (revision 4e578730273a943bb02a2861c694a2707c8ef852) +++ Ringtoets/Common/src/Ringtoets.Common.IO/Ringtoets.Common.IO.csproj (.../Ringtoets.Common.IO.csproj) (revision 60bd3c063c8173f762c5762096efa38b87f780ed) @@ -70,8 +70,11 @@ + + + Index: Ringtoets/Common/src/Ringtoets.Common.IO/Structures/HeightStructuresCharacteristicsCsvReader.cs =================================================================== diff -u --- Ringtoets/Common/src/Ringtoets.Common.IO/Structures/HeightStructuresCharacteristicsCsvReader.cs (revision 0) +++ Ringtoets/Common/src/Ringtoets.Common.IO/Structures/HeightStructuresCharacteristicsCsvReader.cs (revision 60bd3c063c8173f762c5762096efa38b87f780ed) @@ -0,0 +1,75 @@ +// Copyright (C) Stichting Deltares 2016. 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.IO; +using Core.Common.IO.Exceptions; +using Core.Common.IO.Readers; +using Core.Common.Utils; + +namespace Ringtoets.Common.IO.Structures +{ + /// + /// File reader for a plain text file in comma-separated values format (*.csv) containing + /// data specifying characteristics of height structures. + /// + public class HeightStructuresCharacteristicsCsvReader + { + private readonly string filePath; + + /// + /// Creates a new instance of + /// and opens a given file path. + /// + /// The path to the file to be read. + /// Thrown when is invalid. + public HeightStructuresCharacteristicsCsvReader(string path) + { + FileUtils.ValidateFilePath(path); + + filePath = path; + } + + /// + /// Reads the given file and extract all from + /// it and organizes them based on location. + /// + /// Returns a dictionary with 'location ID' being the key and all associated + /// that were read from the file. + /// File/directory cannot be found or + /// some other I/O related problem occurred. + public IDictionary> ReadAllData() + { + using (StreamReader reader = StreamReaderHelper.InitializeStreamReader(filePath)) + { + // Validate file exists + // Read 1st line: Index header + // For every remaining line + // Skip if empty + // Tokenize line + // Parse token values into StructuresParameterRow + // Add StructuresParameterRow to correct location + return new Dictionary>(); + } + } + } +} \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.IO/Structures/StructuresParameterRow.cs =================================================================== diff -u --- Ringtoets/Common/src/Ringtoets.Common.IO/Structures/StructuresParameterRow.cs (revision 0) +++ Ringtoets/Common/src/Ringtoets.Common.IO/Structures/StructuresParameterRow.cs (revision 60bd3c063c8173f762c5762096efa38b87f780ed) @@ -0,0 +1,67 @@ +// Copyright (C) Stichting Deltares 2016. 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. + +namespace Ringtoets.Common.IO.Structures +{ + /// + /// This class represents a definition of some structure-parameter that has been defined + /// in a *.csv file. + /// + public class StructuresParameterRow + { + /// + /// Initializes a new instance of the class. + /// + public StructuresParameterRow() + { + NumericalValue = double.NaN; + VarianceValue = double.NaN; + LineNumber = -1; + } + + /// + /// Gets or sets the ID of this parameter. + /// + public string ParameterId { get; set; } + + /// + /// Gets or sets the numerical value (interpreted as the mean of a random variable + /// or as deterministic value) for the parameter. + /// + public double NumericalValue { get; set; } + + /// + /// Gets or sets the variance value (interpreted as the standard deviation of a + /// random variable or a the coefficient of variation of a random variable). + /// + public double VarianceValue { get; set; } + + /// + /// Gets or sets the type that defines how should be interpreted. + /// + public VarianceType VarianceType { get; set; } + + /// + /// Gets or sets the line number of where this parameter was defined. + /// + public int LineNumber { get; set; } + } +} \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.IO/Structures/VarianceType.cs =================================================================== diff -u --- Ringtoets/Common/src/Ringtoets.Common.IO/Structures/VarianceType.cs (revision 0) +++ Ringtoets/Common/src/Ringtoets.Common.IO/Structures/VarianceType.cs (revision 60bd3c063c8173f762c5762096efa38b87f780ed) @@ -0,0 +1,46 @@ +// Copyright (C) Stichting Deltares 2016. 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. + +namespace Ringtoets.Common.IO.Structures +{ + /// + /// Describes how the should be interpreted. + /// + public enum VarianceType + { + /// + /// It hasn't been specified how the property should be interpreted. This could mean + /// the origin was lacking information or because the value is considered deterministic. + /// + NotSpecified, + + /// + /// The property should be interpreted as the standard deviation of a random variable. + /// + StandardDeviation, + + /// + /// The property should be interpreted as the coefficient of variation + /// (standard deviation / mean). + /// + CoefficientOfVariation + } +} \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/Ringtoets.Common.IO.Test.csproj =================================================================== diff -u -r4e578730273a943bb02a2861c694a2707c8ef852 -r60bd3c063c8173f762c5762096efa38b87f780ed --- Ringtoets/Common/test/Ringtoets.Common.IO.Test/Ringtoets.Common.IO.Test.csproj (.../Ringtoets.Common.IO.Test.csproj) (revision 4e578730273a943bb02a2861c694a2707c8ef852) +++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/Ringtoets.Common.IO.Test.csproj (.../Ringtoets.Common.IO.Test.csproj) (revision 60bd3c063c8173f762c5762096efa38b87f780ed) @@ -68,6 +68,8 @@ + + @@ -84,6 +86,10 @@ {e344867e-9ac9-44c8-88a5-8185681679a9} Core.Common.IO + + {f49bd8b2-332a-4c91-a196-8cce0a2c7d98} + Core.Common.Utils + {d749ee4c-ce50-4c17-bf01-9a953028c126} Core.Common.TestUtil Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/Structures/HeightStructuresCharacteristicsCsvReaderTest.cs =================================================================== diff -u --- Ringtoets/Common/test/Ringtoets.Common.IO.Test/Structures/HeightStructuresCharacteristicsCsvReaderTest.cs (revision 0) +++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/Structures/HeightStructuresCharacteristicsCsvReaderTest.cs (revision 60bd3c063c8173f762c5762096efa38b87f780ed) @@ -0,0 +1,83 @@ +// Copyright (C) Stichting Deltares 2016. 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.IO; +using Core.Common.TestUtil; +using Core.Common.Utils.Builders; +using NUnit.Framework; +using Ringtoets.Common.IO.Structures; +using UtilsResources = Core.Common.Utils.Properties.Resources; + +namespace Ringtoets.Common.IO.Test.Structures +{ + [TestFixture] + public class HeightStructuresCharacteristicsCsvReaderTest + { + private readonly string testDataPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.HeightStructures.IO, string.Format("Characteristics{0}", Path.DirectorySeparatorChar)); + + [Test] + [TestCase("")] + [TestCase(null)] + [TestCase(" ")] + public void Constructor_InvalidStringArgument_ThrowsArgumentException(string path) + { + // Call + TestDelegate call = () => new HeightStructuresCharacteristicsCsvReader(path); + + // Assert + string expectedMessage = new FileReaderErrorMessageBuilder(path).Build(UtilsResources.Error_Path_must_be_specified); + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage); + } + + [Test] + public void Constructor_InvalidPathCharactersInPath_ThrowsArgumentException() + { + // Setup + string path = Path.Combine(testDataPath, "ValidCharacteristics.csv"); + + char[] invalidCharacters = Path.GetInvalidPathChars(); + + string corruptPath = path.Replace('V', invalidCharacters[0]); + + // Call + TestDelegate call = () => new HeightStructuresCharacteristicsCsvReader(corruptPath); + + // Assert + string innerExpectedMessage = string.Format((string) UtilsResources.Error_Path_cannot_contain_Characters_0_, + string.Join(", ", Path.GetInvalidFileNameChars())); + string expectedMessage = new FileReaderErrorMessageBuilder(corruptPath).Build(innerExpectedMessage); + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage); + } + + [Test] + public void Constructor_PathToFolder_ThrowsArgumentException() + { + // Call + TestDelegate call = () => new HeightStructuresCharacteristicsCsvReader(testDataPath); + + // Assert + ArgumentException exception = Assert.Throws(call); + string expectedMessage = new FileReaderErrorMessageBuilder(testDataPath).Build(UtilsResources.Error_Path_must_not_point_to_empty_file_name); + Assert.AreEqual(expectedMessage, exception.Message); + } + } +} \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/Structures/StructuresParameterRowTest.cs =================================================================== diff -u --- Ringtoets/Common/test/Ringtoets.Common.IO.Test/Structures/StructuresParameterRowTest.cs (revision 0) +++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/Structures/StructuresParameterRowTest.cs (revision 60bd3c063c8173f762c5762096efa38b87f780ed) @@ -0,0 +1,67 @@ +// Copyright (C) Stichting Deltares 2016. 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 NUnit.Framework; +using Ringtoets.Common.IO.Structures; + +namespace Ringtoets.Common.IO.Test.Structures +{ + [TestFixture] + public class StructuresParameterRowTest + { + [Test] + public void Constructor_ExpectedValues() + { + // Call + var parameter = new StructuresParameterRow(); + + // Assert + Assert.IsNull(parameter.ParameterId); + Assert.IsNaN(parameter.NumericalValue); + Assert.IsNaN(parameter.VarianceValue); + Assert.AreEqual(VarianceType.NotSpecified, parameter.VarianceType); + Assert.AreEqual(-1, parameter.LineNumber); + } + + [Test] + [TestCase("A", 1.1, -2.2, VarianceType.CoefficientOfVariation, 4)] + [TestCase("B", -3.3, 4.4, VarianceType.StandardDeviation, 96758)] + public void SimpleProperties_SetNewValues_GetNewlySetValues(string id, double numerical, double variance, VarianceType type, int lineNumber) + { + // Setup + var parameter = new StructuresParameterRow(); + + // Call + parameter.ParameterId = id; + parameter.NumericalValue = numerical; + parameter.VarianceValue = variance; + parameter.VarianceType = type; + parameter.LineNumber = lineNumber; + + // Assert + Assert.AreEqual(id, parameter.ParameterId); + Assert.AreEqual(numerical, parameter.NumericalValue); + Assert.AreEqual(variance, parameter.VarianceValue); + Assert.AreEqual(type, parameter.VarianceType); + Assert.AreEqual(lineNumber, parameter.LineNumber); + } + } +} \ No newline at end of file Fisheye: Tag 60bd3c063c8173f762c5762096efa38b87f780ed refers to a dead (removed) revision in file `Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.IO/HeightStructuresCharacteristicsCsvReader.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.IO/Ringtoets.HeightStructures.IO.csproj =================================================================== diff -u -r3bbcb9e79264c1031d399da357be326c48f4e5f4 -r60bd3c063c8173f762c5762096efa38b87f780ed --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.IO/Ringtoets.HeightStructures.IO.csproj (.../Ringtoets.HeightStructures.IO.csproj) (revision 3bbcb9e79264c1031d399da357be326c48f4e5f4) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.IO/Ringtoets.HeightStructures.IO.csproj (.../Ringtoets.HeightStructures.IO.csproj) (revision 60bd3c063c8173f762c5762096efa38b87f780ed) @@ -39,27 +39,13 @@ Properties\GlobalAssembly.cs - - - Copying.licenseheader - - - {e344867e-9ac9-44c8-88a5-8185681679a9} - Core.Common.IO - - - {F49BD8B2-332A-4C91-A196-8CCE0A2C7D98} - Core.Common.Utils - False - -