From 1b3fe5e6a32a7315e388e30f8f1e63fa926615e6 Mon Sep 17 00:00:00 2001 From: Michal Ciszewski Date: Mon, 12 Oct 2015 15:46:51 +0200 Subject: [PATCH 1/4] Rename tests classes and methods --- ...alDataTest.cs => BicubicCalculatorExternalDataTest.cs} | 2 +- ...leTests.cs => BicubicCalculatorWrongArgumentsTests.cs} | 8 ++++---- src/NSrtm.Core.xTests/NSrtm.Core.xTests.csproj | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) rename src/NSrtm.Core.xTests/{Spline3DCalculatorExternalDataTest.cs => BicubicCalculatorExternalDataTest.cs} (96%) rename src/NSrtm.Core.xTests/{Spline3DCalculatorSimpleTests.cs => BicubicCalculatorWrongArgumentsTests.cs} (92%) diff --git a/src/NSrtm.Core.xTests/Spline3DCalculatorExternalDataTest.cs b/src/NSrtm.Core.xTests/BicubicCalculatorExternalDataTest.cs similarity index 96% rename from src/NSrtm.Core.xTests/Spline3DCalculatorExternalDataTest.cs rename to src/NSrtm.Core.xTests/BicubicCalculatorExternalDataTest.cs index 2752a15..a17abb0 100644 --- a/src/NSrtm.Core.xTests/Spline3DCalculatorExternalDataTest.cs +++ b/src/NSrtm.Core.xTests/BicubicCalculatorExternalDataTest.cs @@ -4,7 +4,7 @@ namespace NSrtm.Core.xTests { - public class Spline3DCalculatorExternalDataTest + public class BicubicCalculatorExternalDataTest { [Theory] [MemberData("ExternalData")] diff --git a/src/NSrtm.Core.xTests/Spline3DCalculatorSimpleTests.cs b/src/NSrtm.Core.xTests/BicubicCalculatorWrongArgumentsTests.cs similarity index 92% rename from src/NSrtm.Core.xTests/Spline3DCalculatorSimpleTests.cs rename to src/NSrtm.Core.xTests/BicubicCalculatorWrongArgumentsTests.cs index b1d1314..113a6d0 100644 --- a/src/NSrtm.Core.xTests/Spline3DCalculatorSimpleTests.cs +++ b/src/NSrtm.Core.xTests/BicubicCalculatorWrongArgumentsTests.cs @@ -5,7 +5,7 @@ namespace NSrtm.Core.xTests { - public class Spline3DCalculatorSimpleTests + public class BicubicCalculatorWrongArgumentsTests { [Fact] public void EmptyValuesContainerThrowsArgumentNullException() @@ -14,7 +14,7 @@ public void EmptyValuesContainerThrowsArgumentNullException() } [Fact] - public void ValuesWithWrongSizeDimensionThrowsArgumentNullException() + public void ValuesWithWrongSizeDimensionThrowsArgumentException() { Assert.Throws( () => @@ -29,7 +29,7 @@ public void ValuesWithWrongSizeDimensionThrowsArgumentNullException() } [Fact] - public void ZeroStepThrowsArgumentNullException() + public void ZeroStepThrowsArgumentOutOfRangeException() { Assert.Throws( () => @@ -44,7 +44,7 @@ public void ZeroStepThrowsArgumentNullException() } [Fact] - public void NegativeStepThrowsArgumentNullException() + public void NegativeStepThrowsArgumentOutOfRangeException() { Assert.Throws( () => diff --git a/src/NSrtm.Core.xTests/NSrtm.Core.xTests.csproj b/src/NSrtm.Core.xTests/NSrtm.Core.xTests.csproj index c18b4a1..16dbfba 100644 --- a/src/NSrtm.Core.xTests/NSrtm.Core.xTests.csproj +++ b/src/NSrtm.Core.xTests/NSrtm.Core.xTests.csproj @@ -82,8 +82,8 @@ - - + + From 8ad973d899ba7ba1bc2881729a26feb6ccf34158 Mon Sep 17 00:00:00 2001 From: Michal Ciszewski Date: Mon, 12 Oct 2015 16:08:50 +0200 Subject: [PATCH 2/4] Create folder for BicubicinterpolationTests --- .../BicubicCalculatorExternalDataTest.cs | 2 +- .../BicubicCalculatorWrongArgumentsTests.cs | 2 +- src/NSrtm.Core.xTests/NSrtm.Core.xTests.csproj | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) rename src/NSrtm.Core.xTests/{ => BicubicInterpolation}/BicubicCalculatorExternalDataTest.cs (97%) rename src/NSrtm.Core.xTests/{ => BicubicInterpolation}/BicubicCalculatorWrongArgumentsTests.cs (98%) diff --git a/src/NSrtm.Core.xTests/BicubicCalculatorExternalDataTest.cs b/src/NSrtm.Core.xTests/BicubicInterpolation/BicubicCalculatorExternalDataTest.cs similarity index 97% rename from src/NSrtm.Core.xTests/BicubicCalculatorExternalDataTest.cs rename to src/NSrtm.Core.xTests/BicubicInterpolation/BicubicCalculatorExternalDataTest.cs index a17abb0..087267b 100644 --- a/src/NSrtm.Core.xTests/BicubicCalculatorExternalDataTest.cs +++ b/src/NSrtm.Core.xTests/BicubicInterpolation/BicubicCalculatorExternalDataTest.cs @@ -2,7 +2,7 @@ using NSrtm.Core.BicubicInterpolation; using Xunit; -namespace NSrtm.Core.xTests +namespace NSrtm.Core.xTests.BicubicInterpolation { public class BicubicCalculatorExternalDataTest { diff --git a/src/NSrtm.Core.xTests/BicubicCalculatorWrongArgumentsTests.cs b/src/NSrtm.Core.xTests/BicubicInterpolation/BicubicCalculatorWrongArgumentsTests.cs similarity index 98% rename from src/NSrtm.Core.xTests/BicubicCalculatorWrongArgumentsTests.cs rename to src/NSrtm.Core.xTests/BicubicInterpolation/BicubicCalculatorWrongArgumentsTests.cs index 113a6d0..0e8f7e9 100644 --- a/src/NSrtm.Core.xTests/BicubicCalculatorWrongArgumentsTests.cs +++ b/src/NSrtm.Core.xTests/BicubicInterpolation/BicubicCalculatorWrongArgumentsTests.cs @@ -3,7 +3,7 @@ using NSrtm.Core.BicubicInterpolation; using Xunit; -namespace NSrtm.Core.xTests +namespace NSrtm.Core.xTests.BicubicInterpolation { public class BicubicCalculatorWrongArgumentsTests { diff --git a/src/NSrtm.Core.xTests/NSrtm.Core.xTests.csproj b/src/NSrtm.Core.xTests/NSrtm.Core.xTests.csproj index 16dbfba..f1c2aaa 100644 --- a/src/NSrtm.Core.xTests/NSrtm.Core.xTests.csproj +++ b/src/NSrtm.Core.xTests/NSrtm.Core.xTests.csproj @@ -77,13 +77,14 @@ Properties\GlobalAssemblyInfo.cs + - - + + From 1d5aacad375867fffc54e3ee9e428bc22fad4564 Mon Sep 17 00:00:00 2001 From: Michal Ciszewski Date: Mon, 12 Oct 2015 16:10:28 +0200 Subject: [PATCH 3/4] Add simple plane tests for bicubic calculator --- .../BicubicCalculatorSimplePlaneTests.cs | 82 +++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 src/NSrtm.Core.xTests/BicubicInterpolation/BicubicCalculatorSimplePlaneTests.cs diff --git a/src/NSrtm.Core.xTests/BicubicInterpolation/BicubicCalculatorSimplePlaneTests.cs b/src/NSrtm.Core.xTests/BicubicInterpolation/BicubicCalculatorSimplePlaneTests.cs new file mode 100644 index 0000000..d483ecc --- /dev/null +++ b/src/NSrtm.Core.xTests/BicubicInterpolation/BicubicCalculatorSimplePlaneTests.cs @@ -0,0 +1,82 @@ +using System.Collections.Generic; +using System.Linq; +using NSrtm.Core.BicubicInterpolation; +using Xunit; + +namespace NSrtm.Core.xTests.BicubicInterpolation +{ + public class BicubicCalculatorSimplePlaneTests + { + [Theory] + [MemberData("SimplePlane")] + public void BicubicSplineCalculatorReturnsSimilarResultForNodes( + List> values, + double step) + { + var spline = BicubicCalculator.GetSpline(values, step); + var nodes = Enumerable.Range(0, 2); + var positions = nodes.SelectMany(x => nodes.Select(y => new {x, y})) + .ToList(); + foreach (var position in positions) + { + var result = spline.Evaluate(position.x, position.y); + var expected = values[position.x + 1][position.y + 1]; + AssertDeep.Equal(result, expected, config => config.DoublePrecision = 1e-5); + } + } + + [Theory] + [MemberData("SimplePlane")] + public void BicubicSplineCalculatorReturnsCorrectResultsForSpaceBetweenNodes( + List> values, + double step) + { + var spline = BicubicCalculator.GetSpline(values, step); + var nodes = Enumerable.Range(0, 11).Select(p=>p*0.1); + var positions = nodes.SelectMany(x => nodes.Select(y => new {x, y})) + .ToList(); + var expected = values[0][0]; + foreach (var position in positions) + { + var result = spline.Evaluate(position.x, position.y); + AssertDeep.Equal(result, expected, config => config.DoublePrecision = 1e-5); + } + } + + #region Static Members + + public static IReadOnlyList SimplePlane + { + get + { + return new List + { + new object[] + { + new List> + { + new List {10, 10, 10, 10}, + new List {10, 10, 10, 10}, + new List {10, 10, 10, 10}, + new List {10, 10, 10, 10}, + }, + 1 + }, + new object[] + { + new List> + { + new List {-10, -10, -10, -10}, + new List {-10, -10, -10, -10}, + new List {-10, -10, -10, -10}, + new List {-10, -10, -10, -10}, + }, + 1 + } + }; + } + } + + #endregion + } +} From d80b0e9bdbdd75e08391d5ff4d6ab35280a77481 Mon Sep 17 00:00:00 2001 From: Michal Ciszewski Date: Mon, 12 Oct 2015 16:18:29 +0200 Subject: [PATCH 4/4] Change test cases to more varied --- .../BicubicCalculatorSimplePlaneTests.cs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/NSrtm.Core.xTests/BicubicInterpolation/BicubicCalculatorSimplePlaneTests.cs b/src/NSrtm.Core.xTests/BicubicInterpolation/BicubicCalculatorSimplePlaneTests.cs index d483ecc..7a1522d 100644 --- a/src/NSrtm.Core.xTests/BicubicInterpolation/BicubicCalculatorSimplePlaneTests.cs +++ b/src/NSrtm.Core.xTests/BicubicInterpolation/BicubicCalculatorSimplePlaneTests.cs @@ -66,10 +66,21 @@ public static IReadOnlyList SimplePlane { new List> { - new List {-10, -10, -10, -10}, - new List {-10, -10, -10, -10}, - new List {-10, -10, -10, -10}, - new List {-10, -10, -10, -10}, + new List {-0.5, -0.5, -0.5, -0.5}, + new List {-0.5, -0.5, -0.5, -0.5}, + new List {-0.5, -0.5, -0.5, -0.5}, + new List {-0.5, -0.5, -0.5, -0.5}, + }, + 1 + }, + new object[] + { + new List> + { + new List {0, 0, 0, 0}, + new List {0, 0, 0, 0}, + new List {0, 0, 0, 0}, + new List {0, 0, 0, 0}, }, 1 }