Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down
Original file line number Diff line number Diff line change
@@ -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<List<double>> 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<List<double>> 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<object[]> SimplePlane
{
get
{
return new List<object[]>
{
new object[]
{
new List<List<double>>
{
new List<double> {10, 10, 10, 10},
new List<double> {10, 10, 10, 10},
new List<double> {10, 10, 10, 10},
new List<double> {10, 10, 10, 10},
},
1
},
new object[]
{
new List<List<double>>
{
new List<double> {-0.5, -0.5, -0.5, -0.5},
new List<double> {-0.5, -0.5, -0.5, -0.5},
new List<double> {-0.5, -0.5, -0.5, -0.5},
new List<double> {-0.5, -0.5, -0.5, -0.5},
},
1
},
new object[]
{
new List<List<double>>
{
new List<double> {0, 0, 0, 0},
new List<double> {0, 0, 0, 0},
new List<double> {0, 0, 0, 0},
new List<double> {0, 0, 0, 0},
},
1
}
};
}
}

#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -14,7 +14,7 @@ public void EmptyValuesContainerThrowsArgumentNullException()
}

[Fact]
public void ValuesWithWrongSizeDimensionThrowsArgumentNullException()
public void ValuesWithWrongSizeDimensionThrowsArgumentException()
{
Assert.Throws<ArgumentException>(
() =>
Expand All @@ -29,7 +29,7 @@ public void ValuesWithWrongSizeDimensionThrowsArgumentNullException()
}

[Fact]
public void ZeroStepThrowsArgumentNullException()
public void ZeroStepThrowsArgumentOutOfRangeException()
{
Assert.Throws<ArgumentOutOfRangeException>(
() =>
Expand All @@ -44,7 +44,7 @@ public void ZeroStepThrowsArgumentNullException()
}

[Fact]
public void NegativeStepThrowsArgumentNullException()
public void NegativeStepThrowsArgumentOutOfRangeException()
{
Assert.Throws<ArgumentOutOfRangeException>(
() =>
Expand Down
5 changes: 3 additions & 2 deletions src/NSrtm.Core.xTests/NSrtm.Core.xTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,14 @@
<Link>Properties\GlobalAssemblyInfo.cs</Link>
</Compile>
<Compile Include="AssertDeep.cs" />
<Compile Include="BicubicInterpolation\BicubicCalculatorSimplePlaneTests.cs" />
<Compile Include="CoordinatesNormalizationToEgmDatumTests.cs" />
<Compile Include="PgmDataDescriptionExtractorTests.cs" />
<Compile Include="PgmElevationProviderCoordinatesFindingTests.cs" />
<Compile Include="PgmPreamblesHelper.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Spline3DCalculatorSimpleTests.cs" />
<Compile Include="Spline3DCalculatorExternalDataTest.cs" />
<Compile Include="BicubicInterpolation\BicubicCalculatorWrongArgumentsTests.cs" />
<Compile Include="BicubicInterpolation\BicubicCalculatorExternalDataTest.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\NSrtm.Core\NSrtm.Core.csproj">
Expand Down