Index: Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.KernelWrapper.TestUtil.Test/Kernels/UpliftVan/Input/CurveComparerTest.cs =================================================================== diff -u -r3e96590dbc35797c9eed68f737c44fb94c585071 -rbd2417840f7f90c6176fec8c18db723ca7ab2e38 --- Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.KernelWrapper.TestUtil.Test/Kernels/UpliftVan/Input/CurveComparerTest.cs (.../CurveComparerTest.cs) (revision 3e96590dbc35797c9eed68f737c44fb94c585071) +++ Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.KernelWrapper.TestUtil.Test/Kernels/UpliftVan/Input/CurveComparerTest.cs (.../CurveComparerTest.cs) (revision bd2417840f7f90c6176fec8c18db723ca7ab2e38) @@ -19,6 +19,9 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; +using System.Collections; +using System.Collections.Generic; using Deltares.MacroStability.CSharpWrapper; using Deltares.MacroStability.CSharpWrapper.Input; using NUnit.Framework; @@ -30,6 +33,51 @@ public class CurveComparerTest { [Test] + public void Constructor_ExpectedValues() + { + // Call + var comparer = new CurveComparer(); + + // Assert + Assert.IsInstanceOf(comparer); + Assert.IsInstanceOf>(comparer); + } + + [Test] + public void Compare_FirstObjectOfIncorrectType_ThrowArgumentException() + { + // Setup + var firstObject = new object(); + object secondObject = new Curve(); + + var comparer = new CurveComparer(); + + // Call + void Call() => comparer.Compare(firstObject, secondObject); + + // Assert + var exception = Assert.Throws(Call); + Assert.AreEqual($"Cannot compare objects other than {typeof(Curve)} with this comparer.", exception.Message); + } + + [Test] + public void Compare_SecondObjectOfIncorrectType_ThrowArgumentException() + { + // Setup + object firstObject = new Curve(); + var secondObject = new object(); + + var comparer = new CurveComparer(); + + // Call + void Call() => comparer.Compare(firstObject, secondObject); + + // Assert + var exception = Assert.Throws(Call); + Assert.AreEqual($"Cannot compare objects other than {typeof(Curve)} with this comparer.", exception.Message); + } + + [Test] public void Compare_SameInstance_ReturnZero() { // Setup Index: Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.KernelWrapper.TestUtil.Test/Kernels/UpliftVan/Input/LoopComparerTest.cs =================================================================== diff -u -r3e96590dbc35797c9eed68f737c44fb94c585071 -rbd2417840f7f90c6176fec8c18db723ca7ab2e38 --- Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.KernelWrapper.TestUtil.Test/Kernels/UpliftVan/Input/LoopComparerTest.cs (.../LoopComparerTest.cs) (revision 3e96590dbc35797c9eed68f737c44fb94c585071) +++ Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.KernelWrapper.TestUtil.Test/Kernels/UpliftVan/Input/LoopComparerTest.cs (.../LoopComparerTest.cs) (revision bd2417840f7f90c6176fec8c18db723ca7ab2e38) @@ -19,6 +19,8 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; +using System.Collections; using System.Collections.Generic; using Deltares.MacroStability.CSharpWrapper; using Deltares.MacroStability.CSharpWrapper.Input; @@ -31,6 +33,51 @@ public class LoopComparerTest { [Test] + public void Constructor_ExpectedValues() + { + // Call + var comparer = new LoopComparer(); + + // Assert + Assert.IsInstanceOf(comparer); + Assert.IsInstanceOf>(comparer); + } + + [Test] + public void Compare_FirstObjectOfIncorrectType_ThrowArgumentException() + { + // Setup + var firstObject = new object(); + object secondObject = new Loop(); + + var comparer = new LoopComparer(); + + // Call + void Call() => comparer.Compare(firstObject, secondObject); + + // Assert + var exception = Assert.Throws(Call); + Assert.AreEqual($"Cannot compare objects other than {typeof(Loop)} with this comparer.", exception.Message); + } + + [Test] + public void Compare_SecondObjectOfIncorrectType_ThrowArgumentException() + { + // Setup + object firstObject = new Loop(); + var secondObject = new object(); + + var comparer = new LoopComparer(); + + // Call + void Call() => comparer.Compare(firstObject, secondObject); + + // Assert + var exception = Assert.Throws(Call); + Assert.AreEqual($"Cannot compare objects other than {typeof(Loop)} with this comparer.", exception.Message); + } + + [Test] public void Compare_SameInstance_ReturnZero() { // Setup Index: Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.KernelWrapper.TestUtil.Test/Kernels/UpliftVan/Input/StabilityPointComparerTest.cs =================================================================== diff -u -r3e96590dbc35797c9eed68f737c44fb94c585071 -rbd2417840f7f90c6176fec8c18db723ca7ab2e38 --- Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.KernelWrapper.TestUtil.Test/Kernels/UpliftVan/Input/StabilityPointComparerTest.cs (.../StabilityPointComparerTest.cs) (revision 3e96590dbc35797c9eed68f737c44fb94c585071) +++ Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.KernelWrapper.TestUtil.Test/Kernels/UpliftVan/Input/StabilityPointComparerTest.cs (.../StabilityPointComparerTest.cs) (revision bd2417840f7f90c6176fec8c18db723ca7ab2e38) @@ -47,7 +47,7 @@ { // Setup var firstObject = new object(); - object secondObject = 1.1; + object secondObject = new Point2D(1.1, 1.1); var comparer = new StabilityPointComparer(); @@ -63,7 +63,7 @@ public void Compare_SecondObjectOfIncorrectType_ThrowArgumentException() { // Setup - object firstObject = 2.2; + object firstObject = new Point2D(2.2, 2.2); var secondObject = new object(); var comparer = new StabilityPointComparer(); Index: Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.KernelWrapper.TestUtil/Kernels/UpliftVan/Input/CurveComparer.cs =================================================================== diff -u -r3e96590dbc35797c9eed68f737c44fb94c585071 -rbd2417840f7f90c6176fec8c18db723ca7ab2e38 --- Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.KernelWrapper.TestUtil/Kernels/UpliftVan/Input/CurveComparer.cs (.../CurveComparer.cs) (revision 3e96590dbc35797c9eed68f737c44fb94c585071) +++ Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.KernelWrapper.TestUtil/Kernels/UpliftVan/Input/CurveComparer.cs (.../CurveComparer.cs) (revision bd2417840f7f90c6176fec8c18db723ca7ab2e38) @@ -19,6 +19,7 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; using System.Collections; using System.Collections.Generic; using Deltares.MacroStability.CSharpWrapper; @@ -37,7 +38,11 @@ public int Compare(object x, object y) { - return Compare(x as Curve, y as Curve); + if (!(x is Curve) || !(y is Curve)) + { + throw new ArgumentException($"Cannot compare objects other than {typeof(Curve)} with this comparer."); + } + return Compare((Curve) x, (Curve) y); } public int Compare(Curve x, Curve y) Index: Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.KernelWrapper.TestUtil/Kernels/UpliftVan/Input/LoopComparer.cs =================================================================== diff -u -r3e96590dbc35797c9eed68f737c44fb94c585071 -rbd2417840f7f90c6176fec8c18db723ca7ab2e38 --- Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.KernelWrapper.TestUtil/Kernels/UpliftVan/Input/LoopComparer.cs (.../LoopComparer.cs) (revision 3e96590dbc35797c9eed68f737c44fb94c585071) +++ Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.KernelWrapper.TestUtil/Kernels/UpliftVan/Input/LoopComparer.cs (.../LoopComparer.cs) (revision bd2417840f7f90c6176fec8c18db723ca7ab2e38) @@ -19,6 +19,7 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; using System.Collections; using System.Collections.Generic; using System.Linq; @@ -38,7 +39,11 @@ public int Compare(object x, object y) { - return Compare(x as Loop, y as Loop); + if (!(x is Loop) || !(y is Loop)) + { + throw new ArgumentException($"Cannot compare objects other than {typeof(Loop)} with this comparer."); + } + return Compare((Loop) x, (Loop) y); } public int Compare(Loop x, Loop y)