mirror of https://github.com/oliverbooth/X10D
105 lines
2.5 KiB
C#
105 lines
2.5 KiB
C#
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|||
|
using X10D.Math;
|
|||
|
|
|||
|
namespace X10D.Tests.Math;
|
|||
|
|
|||
|
public partial class Int32Tests
|
|||
|
{
|
|||
|
[TestClass]
|
|||
|
public class WrapTests
|
|||
|
{
|
|||
|
[TestMethod]
|
|||
|
public void Wrap_ShouldReturnLow_WhenValueIsEqualToLow()
|
|||
|
{
|
|||
|
const int value = 10;
|
|||
|
const int low = 10;
|
|||
|
const int high = 20;
|
|||
|
|
|||
|
int result = value.Wrap(low, high);
|
|||
|
|
|||
|
Assert.AreEqual(low, result);
|
|||
|
}
|
|||
|
|
|||
|
[TestMethod]
|
|||
|
public void Wrap_ShouldReturnHigh_WhenValueIsEqualToHigh()
|
|||
|
{
|
|||
|
const int value = 20;
|
|||
|
const int low = 10;
|
|||
|
const int high = 20;
|
|||
|
|
|||
|
int result = value.Wrap(low, high);
|
|||
|
|
|||
|
Assert.AreEqual(low, result);
|
|||
|
}
|
|||
|
|
|||
|
[TestMethod]
|
|||
|
public void Wrap_ShouldReturnCorrectResult_WhenValueIsGreaterThanHigh()
|
|||
|
{
|
|||
|
const int value = 30;
|
|||
|
const int low = 10;
|
|||
|
const int high = 20;
|
|||
|
|
|||
|
int result = value.Wrap(low, high);
|
|||
|
|
|||
|
Assert.AreEqual(low, result);
|
|||
|
}
|
|||
|
|
|||
|
[TestMethod]
|
|||
|
public void Wrap_ShouldReturnCorrectResult_WhenValueIsLessThanLow()
|
|||
|
{
|
|||
|
const int value = 5;
|
|||
|
const int low = 10;
|
|||
|
const int high = 20;
|
|||
|
|
|||
|
int result = value.Wrap(low, high);
|
|||
|
|
|||
|
Assert.AreEqual(15, result);
|
|||
|
}
|
|||
|
|
|||
|
[TestMethod]
|
|||
|
public void Wrap_ShouldReturnCorrectResult_WhenValueIsInBetweenLowAndHigh()
|
|||
|
{
|
|||
|
const int value = 15;
|
|||
|
const int low = 10;
|
|||
|
const int high = 20;
|
|||
|
|
|||
|
int result = value.Wrap(low, high);
|
|||
|
|
|||
|
Assert.AreEqual(value, result);
|
|||
|
}
|
|||
|
|
|||
|
[TestMethod]
|
|||
|
public void Wrap_ShouldReturnZero_WhenValueIsEqualToLength()
|
|||
|
{
|
|||
|
const int value = 10;
|
|||
|
const int length = 10;
|
|||
|
|
|||
|
int result = value.Wrap(length);
|
|||
|
|
|||
|
Assert.AreEqual(0, result);
|
|||
|
}
|
|||
|
|
|||
|
[TestMethod]
|
|||
|
public void Wrap_ShouldReturnValue_WhenValueIsLessThanLength()
|
|||
|
{
|
|||
|
const int value = 5;
|
|||
|
const int length = 10;
|
|||
|
|
|||
|
int result = value.Wrap(length);
|
|||
|
|
|||
|
Assert.AreEqual(value, result);
|
|||
|
}
|
|||
|
|
|||
|
[TestMethod]
|
|||
|
public void Wrap_ShouldReturnCorrectResult_WhenValueIsGreaterThanLength()
|
|||
|
{
|
|||
|
const int value = 15;
|
|||
|
const int length = 10;
|
|||
|
|
|||
|
int result = value.Wrap(length);
|
|||
|
|
|||
|
Assert.AreEqual(5, result);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|