Index: Core/Components/src/Core.Components.Gis/Core.Components.Gis.csproj
===================================================================
diff -u -rcea5eb1070274563792c1e4df8f0fc2228f11913 -r03b2b2080feb05e11d65b29a02760dcdd2651b6e
--- Core/Components/src/Core.Components.Gis/Core.Components.Gis.csproj (.../Core.Components.Gis.csproj) (revision cea5eb1070274563792c1e4df8f0fc2228f11913)
+++ Core/Components/src/Core.Components.Gis/Core.Components.Gis.csproj (.../Core.Components.Gis.csproj) (revision 03b2b2080feb05e11d65b29a02760dcdd2651b6e)
@@ -14,6 +14,8 @@
+
+
Index: Core/Components/src/Core.Components.Gis/Data/Categories/RangeCriteria.cs
===================================================================
diff -u
--- Core/Components/src/Core.Components.Gis/Data/Categories/RangeCriteria.cs (revision 0)
+++ Core/Components/src/Core.Components.Gis/Data/Categories/RangeCriteria.cs (revision 03b2b2080feb05e11d65b29a02760dcdd2651b6e)
@@ -0,0 +1,78 @@
+// 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 Lesser 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 Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser 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.ComponentModel;
+
+namespace Core.Components.Gis.Data.Categories
+{
+ ///
+ /// Criteria which can be used to specifiy ranges.
+ ///
+ public class RangeCriteria : IMapCriteria
+ {
+ ///
+ /// Creates a new instance of .
+ ///
+ ///
+ /// The lower bound of the range.
+ /// The upper bound of the range.
+ /// Thrown when
+ /// contains an invalid value for .
+ /// Thrown when is
+ /// larger or equal to the .
+ public RangeCriteria(RangeCriteriaOperator rangeCriteriaOperator,
+ double lowerBound,
+ double upperBound)
+ {
+ if (!Enum.IsDefined(typeof(RangeCriteriaOperator), rangeCriteriaOperator))
+ {
+ throw new InvalidEnumArgumentException(nameof(rangeCriteriaOperator),
+ (int) rangeCriteriaOperator,
+ typeof(RangeCriteriaOperator));
+ }
+
+ if (lowerBound >= upperBound)
+ {
+ throw new ArgumentException(@"Lower bound cannot be larger or equal than upper bound.", nameof(lowerBound));
+ }
+
+ RangeCriteriaOperator = rangeCriteriaOperator;
+ LowerBound = lowerBound;
+ UpperBound = upperBound;
+ }
+
+ ///
+ /// Gets the operator for the .
+ ///
+ public RangeCriteriaOperator RangeCriteriaOperator { get; }
+
+ ///
+ /// Gets the lower bound of the range.
+ ///
+ public double LowerBound { get; }
+
+ ///
+ /// Gets the upper bound of the range.
+ ///
+ public double UpperBound { get; }
+ }
+}
\ No newline at end of file
Index: Core/Components/src/Core.Components.Gis/Data/Categories/RangeCriteriaOperator.cs
===================================================================
diff -u
--- Core/Components/src/Core.Components.Gis/Data/Categories/RangeCriteriaOperator.cs (revision 0)
+++ Core/Components/src/Core.Components.Gis/Data/Categories/RangeCriteriaOperator.cs (revision 03b2b2080feb05e11d65b29a02760dcdd2651b6e)
@@ -0,0 +1,49 @@
+// 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 Lesser 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 Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser 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 Core.Components.Gis.Data.Categories
+{
+ ///
+ /// Defines the operators of the range criteria operator.
+ ///
+ public enum RangeCriteriaOperator
+ {
+ ///
+ /// Represents an interval: Lower bound <= X <= Upper bound
+ ///
+ AllBoundsInclusive = 1,
+
+ ///
+ /// Represents an interval: Lower bound <= X < Upper bound
+ ///
+ LowerBoundInclusive = 2,
+
+ ///
+ /// Represents an interval: Lower bound < X <= Upper bound
+ ///
+ UpperBoundInclusive = 3,
+
+ ///
+ /// Represents an interval: Lower bound < X < Upper bound
+ ///
+ AllBoundsExclusive = 4
+ }
+}
\ No newline at end of file
Index: Core/Components/test/Core.Components.Gis.Test/Core.Components.Gis.Test.csproj
===================================================================
diff -u -rcea5eb1070274563792c1e4df8f0fc2228f11913 -r03b2b2080feb05e11d65b29a02760dcdd2651b6e
--- Core/Components/test/Core.Components.Gis.Test/Core.Components.Gis.Test.csproj (.../Core.Components.Gis.Test.csproj) (revision cea5eb1070274563792c1e4df8f0fc2228f11913)
+++ Core/Components/test/Core.Components.Gis.Test/Core.Components.Gis.Test.csproj (.../Core.Components.Gis.Test.csproj) (revision 03b2b2080feb05e11d65b29a02760dcdd2651b6e)
@@ -19,6 +19,7 @@
+
Index: Core/Components/test/Core.Components.Gis.Test/Data/Categories/RangeCriteriaTest.cs
===================================================================
diff -u
--- Core/Components/test/Core.Components.Gis.Test/Data/Categories/RangeCriteriaTest.cs (revision 0)
+++ Core/Components/test/Core.Components.Gis.Test/Data/Categories/RangeCriteriaTest.cs (revision 03b2b2080feb05e11d65b29a02760dcdd2651b6e)
@@ -0,0 +1,85 @@
+// 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 Lesser 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 Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser 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.ComponentModel;
+using Core.Common.TestUtil;
+using Core.Components.Gis.Data.Categories;
+using NUnit.Framework;
+
+namespace Core.Components.Gis.Test.Data.Categories
+{
+ [TestFixture]
+ public class RangeCriteriaTest
+ {
+ [Test]
+ public void Constructor_ValidArguments_ReturnsExpectedValues()
+ {
+ // Setup
+ var random = new Random(21);
+
+ var rangeCriteriaOperator = random.NextEnumValue();
+ double lowerBound = random.NextDouble();
+ double upperBound = 1 + random.NextDouble();
+
+ // Call
+ var criteria = new RangeCriteria(rangeCriteriaOperator, lowerBound, upperBound);
+
+ // Assert
+ Assert.IsInstanceOf(criteria);
+ Assert.AreEqual(rangeCriteriaOperator, criteria.RangeCriteriaOperator);
+ Assert.AreEqual(lowerBound, criteria.LowerBound);
+ Assert.AreEqual(upperBound, criteria.UpperBound);
+ }
+
+ [Test]
+ public void Constructor_InvalidRangeCriteriaOperator_ThrownInvalidEnumArgumentException()
+ {
+ // Setup
+ var random = new Random(21);
+ const RangeCriteriaOperator invalidOperator = (RangeCriteriaOperator) 99999;
+
+ // Call
+ TestDelegate call = () => new RangeCriteria(invalidOperator, random.NextDouble(), random.NextDouble());
+
+ // Assert
+ string expectedMessage = $"The value of argument 'rangeCriteriaOperator' ({invalidOperator}) is invalid for Enum type '{nameof(RangeCriteriaOperator)}'.";
+ string parameterName = TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage).ParamName;
+ Assert.AreEqual("rangeCriteriaOperator", parameterName);
+ }
+
+ [Test]
+ [TestCase(10, 10)]
+ [TestCase(11, 10)]
+ public void Constructor_InvalidLowerBound_ThrowsArgumentException(double lowerBound, double upperBound)
+ {
+ // Setup
+ var random = new Random(21);
+
+ // Call
+ TestDelegate call = () => new RangeCriteria(random.NextEnumValue(), lowerBound, upperBound);
+
+ // Assert
+ const string expectedMessage = "Lower bound cannot be larger or equal than upper bound.";
+ TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage);
+ }
+ }
+}
\ No newline at end of file
Index: Core/Components/test/Core.Components.Gis.Test/Data/Categories/ValueCriteriaTest.cs
===================================================================
diff -u -rcea5eb1070274563792c1e4df8f0fc2228f11913 -r03b2b2080feb05e11d65b29a02760dcdd2651b6e
--- Core/Components/test/Core.Components.Gis.Test/Data/Categories/ValueCriteriaTest.cs (.../ValueCriteriaTest.cs) (revision cea5eb1070274563792c1e4df8f0fc2228f11913)
+++ Core/Components/test/Core.Components.Gis.Test/Data/Categories/ValueCriteriaTest.cs (.../ValueCriteriaTest.cs) (revision 03b2b2080feb05e11d65b29a02760dcdd2651b6e)
@@ -52,13 +52,13 @@
{
// Setup
var random = new Random(21);
- const ValueCriteriaOperator invalidValue = (ValueCriteriaOperator) 9999;
+ const ValueCriteriaOperator invalidOperator = (ValueCriteriaOperator) 9999;
// Call
- TestDelegate call = () => new ValueCriteria(invalidValue, random.NextDouble());
+ TestDelegate call = () => new ValueCriteria(invalidOperator, random.NextDouble());
// Assert
- string expectedMessage = $"The value of argument 'valueOperator' ({invalidValue}) is invalid for Enum type '{nameof(ValueCriteriaOperator)}'.";
+ string expectedMessage = $"The value of argument 'valueOperator' ({invalidOperator}) is invalid for Enum type '{nameof(ValueCriteriaOperator)}'.";
string parameterName = TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage).ParamName;
Assert.AreEqual("valueOperator", parameterName);
}