forked from JimBobSquarePants/ImageProcessor
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0237d8f
commit b291455
Showing
2 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
src/ImageProcessor.UnitTests/Extensions/FloatExtensionsUnitTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters