diff --git a/src/NSrtm.Core.xTests/Spline3DCalculatorExternalDataTest.cs b/src/NSrtm.Core.xTests/BicubicInterpolation/BicubicCalculatorExternalDataTest.cs similarity index 93% rename from src/NSrtm.Core.xTests/Spline3DCalculatorExternalDataTest.cs rename to src/NSrtm.Core.xTests/BicubicInterpolation/BicubicCalculatorExternalDataTest.cs index 2752a15..087267b 100644 --- a/src/NSrtm.Core.xTests/Spline3DCalculatorExternalDataTest.cs +++ b/src/NSrtm.Core.xTests/BicubicInterpolation/BicubicCalculatorExternalDataTest.cs @@ -2,9 +2,9 @@ using NSrtm.Core.BicubicInterpolation; using Xunit; -namespace NSrtm.Core.xTests +namespace NSrtm.Core.xTests.BicubicInterpolation { - public class Spline3DCalculatorExternalDataTest + public class BicubicCalculatorExternalDataTest { [Theory] [MemberData("ExternalData")] diff --git a/src/NSrtm.Core.xTests/BicubicInterpolation/BicubicCalculatorSimplePlaneTests.cs b/src/NSrtm.Core.xTests/BicubicInterpolation/BicubicCalculatorSimplePlaneTests.cs new file mode 100644 index 0000000..7a1522d --- /dev/null +++ b/src/NSrtm.Core.xTests/BicubicInterpolation/BicubicCalculatorSimplePlaneTests.cs @@ -0,0 +1,93 @@ +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 {-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 + } + }; + } + } + + #endregion + } +} diff --git a/src/NSrtm.Core.xTests/Spline3DCalculatorSimpleTests.cs b/src/NSrtm.Core.xTests/BicubicInterpolation/BicubicCalculatorWrongArgumentsTests.cs similarity index 91% rename from src/NSrtm.Core.xTests/Spline3DCalculatorSimpleTests.cs rename to src/NSrtm.Core.xTests/BicubicInterpolation/BicubicCalculatorWrongArgumentsTests.cs index b1d1314..0e8f7e9 100644 --- a/src/NSrtm.Core.xTests/Spline3DCalculatorSimpleTests.cs +++ b/src/NSrtm.Core.xTests/BicubicInterpolation/BicubicCalculatorWrongArgumentsTests.cs @@ -3,9 +3,9 @@ using NSrtm.Core.BicubicInterpolation; using Xunit; -namespace NSrtm.Core.xTests +namespace NSrtm.Core.xTests.BicubicInterpolation { - 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..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 + - - + +