Skip to content

Commit

Permalink
Refactored unit tests to NUnit
Browse files Browse the repository at this point in the history
All tests have been convered to NUnit style
NUnit is referenced as a NuGet package
  • Loading branch information
anders9ustafsson committed Nov 28, 2014
1 parent d628a15 commit 032ccbf
Show file tree
Hide file tree
Showing 28 changed files with 733 additions and 742 deletions.
10 changes: 5 additions & 5 deletions Unit Tests/AForge.Imaging.Tests/AForge.Imaging.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,8 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\Release\AForge.Imaging.dll</HintPath>
</Reference>
<Reference Include="Gallio, Version=3.1.0.0, Culture=neutral, PublicKeyToken=eb9cfa67ee6ab36e, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="MbUnit, Version=3.1.0.0, Culture=neutral, PublicKeyToken=eb9cfa67ee6ab36e, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<Reference Include="nunit.framework">
<HintPath>..\packages\NUnit.2.6.3\lib\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core">
Expand Down Expand Up @@ -99,6 +96,9 @@
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
110 changes: 55 additions & 55 deletions Unit Tests/AForge.Imaging.Tests/IntegralImageTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System.Drawing.Imaging;
using AForge;
using AForge.Imaging;
using MbUnit.Framework;
using NUnit.Framework;

namespace AForge.Imaging.Tests
{
Expand All @@ -29,99 +29,99 @@ public IntegralImageTest( )
}

[Test]
[Row( 0, 0, 0, 0, 0 )]
[Row( 0, 0, 1, 0, 1 )]
[Row( 0, 0, 0, 1, 1 )]
[Row( 0, 0, 1, 1, 2 )]
[Row( -1, -1, 1, 1, 2 )]
[Row( 0, 0, 9, 9, 50 )]
[Row( 9, 9, 9, 9, 0 )]
[Row( 9, 9, 10, 10, 0 )]
[TestCase( 0, 0, 0, 0, 0u )]
[TestCase( 0, 0, 1, 0, 1u )]
[TestCase( 0, 0, 0, 1, 1u )]
[TestCase( 0, 0, 1, 1, 2u )]
[TestCase( -1, -1, 1, 1, 2u )]
[TestCase( 0, 0, 9, 9, 50u )]
[TestCase( 9, 9, 9, 9, 0u )]
[TestCase( 9, 9, 10, 10, 0u )]
public void GetRectangleSumTest( int x1, int y1, int x2, int y2, uint expectedSum )
{
uint sum = integralImage.GetRectangleSum( x1, y1, x2, y2 );
Assert.AreEqual<uint>( sum, expectedSum );
Assert.AreEqual( sum, expectedSum );
}

[Test]
[Row( 0, 0, 0, 0, 0 )]
[Row( 0, 0, 1, 0, 1 )]
[Row( 0, 0, 0, 1, 1 )]
[Row( 0, 0, 1, 1, 2 )]
[Row( 0, 0, 9, 9, 50 )]
[Row( 9, 9, 9, 9, 0 )]
[TestCase( 0, 0, 0, 0, 0u )]
[TestCase( 0, 0, 1, 0, 1u )]
[TestCase( 0, 0, 0, 1, 1u )]
[TestCase( 0, 0, 1, 1, 2u )]
[TestCase( 0, 0, 9, 9, 50u )]
[TestCase( 9, 9, 9, 9, 0u )]
public void GetRectangleSumUnsafeTest( int x1, int y1, int x2, int y2, uint expectedSum )
{
uint sum = integralImage.GetRectangleSum( x1, y1, x2, y2 );
Assert.AreEqual<uint>( sum, expectedSum );
Assert.AreEqual( sum, expectedSum );
}

[Test]
[Row( 0, 0, 1, 2 )]
[Row( 1, 1, 1, 4 )]
[Row( 9, 9, 1, 2 )]
[Row( 8, 8, 1, 4 )]
[Row( 2, 1, 1, 5 )]
[TestCase( 0, 0, 1, 2u )]
[TestCase( 1, 1, 1, 4u )]
[TestCase( 9, 9, 1, 2u )]
[TestCase( 8, 8, 1, 4u )]
[TestCase( 2, 1, 1, 5u )]
public void GetRectangleSumTest( int x, int y, int radius, uint expectedSum )
{
uint sum = integralImage.GetRectangleSum( x, y, radius );
Assert.AreEqual<uint>( sum, expectedSum );
Assert.AreEqual( sum, expectedSum );
}

[Test]
[Row( 1, 1, 1, 4 )]
[Row( 8, 8, 1, 4 )]
[Row( 2, 1, 1, 5 )]
[TestCase( 1, 1, 1, 4u )]
[TestCase( 8, 8, 1, 4u )]
[TestCase( 2, 1, 1, 5u )]
public void GetRectangleSumUnsafeTest( int x, int y, int radius, uint expectedSum )
{
uint sum = integralImage.GetRectangleSum( x, y, radius );
Assert.AreEqual<uint>( sum, expectedSum );
Assert.AreEqual( sum, expectedSum );
}

[Test]
[Row( 0, 0, 0, 0, 0 )]
[Row( 0, 0, 1, 0, 0.5 )]
[Row( 0, 0, 0, 1, 0.5 )]
[Row( 0, 0, 1, 1, 0.5 )]
[Row( -1, -1, 1, 1, 0.5 )]
[Row( 0, 0, 9, 9, 0.5 )]
[Row( 9, 9, 9, 9, 0 )]
[Row( 9, 9, 10, 10, 0 )]
[Row( 9, 0, 9, 0, 1 )]
[TestCase( 0, 0, 0, 0, 0 )]
[TestCase( 0, 0, 1, 0, 0.5f )]
[TestCase( 0, 0, 0, 1, 0.5f )]
[TestCase( 0, 0, 1, 1, 0.5f )]
[TestCase( -1, -1, 1, 1, 0.5f )]
[TestCase( 0, 0, 9, 9, 0.5f )]
[TestCase( 9, 9, 9, 9, 0 )]
[TestCase( 9, 9, 10, 10, 0 )]
[TestCase( 9, 0, 9, 0, 1 )]
public void GetRectangleMeanTest( int x1, int y1, int x2, int y2, float expectedMean )
{
float mean = integralImage.GetRectangleMean( x1, y1, x2, y2 );
Assert.AreEqual<float>( mean, expectedMean );
Assert.AreEqual( mean, expectedMean );
}

[Test]
[Row( 1, 1, 1, 0 )]
[Row( 1, 2, 1, 0 )]
[Row( 2, 2, 1, 0 )]
[Row( 2, 2, 2, 0 )]
[Row( 8, 8, 1, 0 )]
[Row( 5, 5, 5, 0 )]
[Row( 0, 1, 1, 1 )]
[Row( 10, 9, 1, -1 )]
[TestCase( 1, 1, 1, 0 )]
[TestCase( 1, 2, 1, 0 )]
[TestCase( 2, 2, 1, 0 )]
[TestCase( 2, 2, 2, 0 )]
[TestCase( 8, 8, 1, 0 )]
[TestCase( 5, 5, 5, 0 )]
[TestCase( 0, 1, 1, 1 )]
[TestCase( 10, 9, 1, -1 )]
public void GetHaarXWavelet( int x, int y, int radius, int expectedValue )
{
int value = integralImage.GetHaarXWavelet( x, y, radius );
Assert.AreEqual<int>( value, expectedValue );
Assert.AreEqual( value, expectedValue );
}

[Test]
[Row( 1, 1, 1, 0 )]
[Row( 1, 2, 1, 0 )]
[Row( 2, 2, 1, 0 )]
[Row( 2, 2, 2, 0 )]
[Row( 8, 8, 1, 0 )]
[Row( 5, 5, 5, 0 )]
[Row( 1, 0, 1, 1 )]
[Row( 9, 10, 1, -1 )]
[TestCase( 1, 1, 1, 0 )]
[TestCase( 1, 2, 1, 0 )]
[TestCase( 2, 2, 1, 0 )]
[TestCase( 2, 2, 2, 0 )]
[TestCase( 8, 8, 1, 0 )]
[TestCase( 5, 5, 5, 0 )]
[TestCase( 1, 0, 1, 1 )]
[TestCase( 9, 10, 1, -1 )]
public void GetHaarYWavelet( int x, int y, int radius, int expectedValue )
{
int value = integralImage.GetHaarYWavelet( x, y, radius );
Assert.AreEqual<int>( value, expectedValue );
Assert.AreEqual( value, expectedValue );
}
}
}
Loading

0 comments on commit 032ccbf

Please sign in to comment.