Skip to content

Commit

Permalink
Added float extensions tests
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherbauer committed Sep 17, 2015
1 parent 0237d8f commit b291455
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
namespace ImageProcessor.UnitTests.Extensions
{
using ImageProcessor.Common.Extensions;

using NUnit.Framework;

/// <summary>
/// The float extensions unit tests.
/// </summary>
public class FloatExtensionsUnitTests
{
/// <summary>
/// The when to byte.
/// </summary>
[TestFixture]
public class WhenToByte
{
/// <summary>
/// The then should constrain input to 255 given float more than 255.
/// </summary>
/// <param name="value">
/// The value.
/// </param>
[Test]
[TestCase(256)]
[TestCase(512)]
[TestCase(1024)]
public void ThenShouldConstrainInputTo255GivenFloatMoreThan255(float value)
{
// Arrange // Act
var result = value.ToByte();

// Assert
Assert.That(result, Is.EqualTo(255));
}

/// <summary>
/// The then should constrain input to 0 given float less than 0.
/// </summary>
/// <param name="value">
/// The value.
/// </param>
[Test]
[TestCase(-256)]
[TestCase(-512)]
[TestCase(-1024)]
public void ThenShouldConstrainInputTo0GivenFloatLessThan0(float value)
{
// Arrange // Act
var result = value.ToByte();

// Assert
Assert.That(result, Is.EqualTo(0));
}

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
<ItemGroup>
<Compile Include="AssertionHelpers.cs" />
<Compile Include="Configuration\ImageProcessorBootstrapperTests.cs" />
<Compile Include="Extensions\FloatExtensionsUnitTests.cs" />
<Compile Include="ImageFactoryUnitTests.cs">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Compile>
Expand Down

0 comments on commit b291455

Please sign in to comment.