restructure tests

master
Evan Hemsley 2019-10-29 18:17:50 -07:00
parent 606fed9878
commit 251391216f
1 changed files with 174 additions and 159 deletions

View File

@ -8,207 +8,222 @@ namespace Test
{ {
public class EasingTests public class EasingTests
{ {
[Test] public static void CheckFloatArguments(Func<float, float> easingNormalizedFunction, Func<float, float, float, float> easingRangeFunction)
public void Linear()
{ {
Easing.Linear(0.25f).Should().Be(0.25f); Action invalidTime = () => easingNormalizedFunction(1.5f);
Easing.Linear(0.5f).Should().Be(0.5f);
Easing.Linear(0.75f).Should().Be(0.75f);
Action invalidTime = () => Easing.Linear(1.5f);
invalidTime.Should().Throw<ArgumentException>(); invalidTime.Should().Throw<ArgumentException>();
Easing.Linear(0.25).Should().Be(0.25); invalidTime = () => easingRangeFunction(7, 2, 6);
Easing.Linear(0.5).Should().Be(0.5);
Easing.Linear(0.75).Should().Be(0.75);
invalidTime = () => Easing.Linear(1.5);
invalidTime.Should().Throw<ArgumentException>(); invalidTime.Should().Throw<ArgumentException>();
Easing.Linear(3, 2, 6).Should().Be(3f);
Easing.Linear(4, 2, 6).Should().Be(4f);
Easing.Linear(5, 2, 6).Should().Be(5f);
invalidTime = () => Easing.Linear(7, 2, 6);
invalidTime.Should().Throw<ArgumentException>();
Easing.Linear(3, 2, 6).Should().Be(3);
Easing.Linear(4, 2, 6).Should().Be(4);
Easing.Linear(5, 2, 6).Should().Be(5);
} }
[Test] public static void CheckDoubleArguments(Func<double, double> easingNormalizedFunction, Func<double, double, double, double> easingRangeFunction)
public void InQuad()
{ {
Easing.InQuad(0.25f).Should().Be(0.0625f); Action invalidTime = () => easingNormalizedFunction(1.5);
Easing.InQuad(0.5f).Should().Be(0.25f);
Easing.InQuad(0.75f).Should().Be(0.5625f);
Action invalidTime = () => Easing.InQuad(1.5f);
invalidTime.Should().Throw<ArgumentException>(); invalidTime.Should().Throw<ArgumentException>();
Easing.InQuad(0.25).Should().Be(0.0625); invalidTime = () => easingRangeFunction(7, 2, 6);
Easing.InQuad(0.5).Should().Be(0.25);
Easing.InQuad(0.75).Should().Be(0.5625);
invalidTime = () => Easing.InQuad(1.5);
invalidTime.Should().Throw<ArgumentException>(); invalidTime.Should().Throw<ArgumentException>();
Easing.InQuad(3, 2, 6).Should().Be(2.25f);
Easing.InQuad(4, 2, 6).Should().Be(3f);
Easing.InQuad(5, 2, 6).Should().Be(4.25f);
invalidTime = () => Easing.InQuad(7, 2, 6);
invalidTime.Should().Throw<ArgumentException>();
Easing.InQuad(3.0, 2, 6).Should().Be(2.25);
Easing.InQuad(4.0, 2, 6).Should().Be(3);
Easing.InQuad(5.0, 2, 6).Should().Be(4.25);
} }
[Test] public class FloatTests
public void OutQuad()
{ {
Easing.OutQuad(0.25f).Should().Be(0.4375f); [Test]
Easing.OutQuad(0.5f).Should().Be(0.75f); public void Linear()
Easing.OutQuad(0.75f).Should().Be(0.9375f); {
Easing.Linear(0.25f).Should().Be(0.25f);
Easing.Linear(0.5f).Should().Be(0.5f);
Easing.Linear(0.75f).Should().Be(0.75f);
Action invalidTime = () => Easing.OutQuad(1.5f); Easing.Linear(3, 2, 6).Should().Be(3f);
invalidTime.Should().Throw<ArgumentException>(); Easing.Linear(4, 2, 6).Should().Be(4f);
Easing.Linear(5, 2, 6).Should().Be(5f);
Easing.OutQuad(0.25).Should().Be(0.4375); CheckFloatArguments(Easing.Linear, Easing.Linear);
Easing.OutQuad(0.5).Should().Be(0.75); }
Easing.OutQuad(0.75).Should().Be(0.9375);
invalidTime = () => Easing.OutQuad(1.5); [Test]
invalidTime.Should().Throw<ArgumentException>(); public void InQuad()
{
Easing.InQuad(0.25f).Should().Be(0.0625f);
Easing.InQuad(0.5f).Should().Be(0.25f);
Easing.InQuad(0.75f).Should().Be(0.5625f);
Easing.OutQuad(3, 2, 6).Should().Be(3.75f); Easing.InQuad(3, 2, 6).Should().Be(2.25f);
Easing.OutQuad(4, 2, 6).Should().Be(5f); Easing.InQuad(4, 2, 6).Should().Be(3f);
Easing.OutQuad(5, 2, 6).Should().Be(5.75f); Easing.InQuad(5, 2, 6).Should().Be(4.25f);
invalidTime = () => Easing.OutQuad(7, 2, 6); CheckFloatArguments(Easing.InQuad, Easing.InQuad);
invalidTime.Should().Throw<ArgumentException>(); }
Easing.OutQuad(3.0, 2, 6).Should().Be(3.75); [Test]
Easing.OutQuad(4.0, 2, 6).Should().Be(5); public void OutQuad()
Easing.OutQuad(5.0, 2, 6).Should().Be(5.75); {
Easing.OutQuad(0.25f).Should().Be(0.4375f);
Easing.OutQuad(0.5f).Should().Be(0.75f);
Easing.OutQuad(0.75f).Should().Be(0.9375f);
Easing.OutQuad(3, 2, 6).Should().Be(3.75f);
Easing.OutQuad(4, 2, 6).Should().Be(5f);
Easing.OutQuad(5, 2, 6).Should().Be(5.75f);
CheckFloatArguments(Easing.OutQuad, Easing.OutQuad);
}
[Test]
public void InOutQuad()
{
Easing.InOutQuad(0.25f).Should().Be(0.125f);
Easing.InOutQuad(0.5f).Should().Be(0.5f);
Easing.InOutQuad(0.75f).Should().Be(0.875f);
Easing.InOutQuad(3, 2, 6).Should().Be(2.5f);
Easing.InOutQuad(4, 2, 6).Should().Be(4f);
Easing.InOutQuad(5, 2, 6).Should().Be(5.5f);
CheckFloatArguments(Easing.InOutQuad, Easing.InOutQuad);
}
[Test]
public void OutInQuad()
{
Easing.OutInQuad(0.25f).Should().Be(0.375f);
Easing.OutInQuad(0.5f).Should().Be(0.5f);
Easing.OutInQuad(0.75f).Should().Be(0.625f);
Easing.OutInQuad(3, 2, 6).Should().Be(3.5f);
Easing.OutInQuad(4, 2, 6).Should().Be(4f);
Easing.OutInQuad(5, 2, 6).Should().Be(4.5f);
CheckFloatArguments(Easing.OutInQuad, Easing.OutInQuad);
}
[Test]
public void InCubic()
{
Easing.InCubic(0.25f).Should().Be(0.015625f);
Easing.InCubic(0.5f).Should().Be(0.125f);
Easing.InCubic(0.75f).Should().Be(0.421875f);
Easing.InCubic(3, 2, 6).Should().Be(2.0625f);
Easing.InCubic(4, 2, 6).Should().Be(2.5f);
Easing.InCubic(5, 2, 6).Should().Be(3.6875f);
CheckFloatArguments(Easing.InCubic, Easing.InCubic);
}
[Test]
public void OutCubic()
{
Easing.OutCubic(0.25f).Should().Be(0.578125f);
Easing.OutCubic(0.5f).Should().Be(0.875f);
Easing.OutCubic(0.75f).Should().Be(0.984375f);
Easing.OutCubic(3, 2, 6).Should().Be(4.3125f);
Easing.OutCubic(4, 2, 6).Should().Be(5.5f);
Easing.OutCubic(5, 2, 6).Should().Be(5.9375f);
}
} }
[Test] public class DoubleTests
public void InOutQuad()
{ {
Easing.InOutQuad(0.25f).Should().Be(0.125f); [Test]
Easing.InOutQuad(0.5f).Should().Be(0.5f); public void Linear()
Easing.InOutQuad(0.75f).Should().Be(0.875f); {
Easing.Linear(0.25).Should().Be(0.25);
Easing.Linear(0.5).Should().Be(0.5);
Easing.Linear(0.75).Should().Be(0.75);
Action invalidTime = () => Easing.InOutQuad(1.5f); Easing.Linear(3.0, 2, 6).Should().Be(3);
invalidTime.Should().Throw<ArgumentException>(); Easing.Linear(4.0, 2, 6).Should().Be(4);
Easing.Linear(5.0, 2, 6).Should().Be(5);
Easing.InOutQuad(0.25).Should().Be(0.125); CheckDoubleArguments(Easing.Linear, Easing.Linear);
Easing.InOutQuad(0.5).Should().Be(0.5); }
Easing.InOutQuad(0.75).Should().Be(0.875);
invalidTime = () => Easing.InOutQuad(1.5); [Test]
invalidTime.Should().Throw<ArgumentException>(); public void InQuad()
{
Easing.InQuad(0.25).Should().Be(0.0625);
Easing.InQuad(0.5).Should().Be(0.25);
Easing.InQuad(0.75).Should().Be(0.5625);
Easing.InOutQuad(3, 2, 6).Should().Be(2.5f); Easing.InQuad(3.0, 2, 6).Should().Be(2.25);
Easing.InOutQuad(4, 2, 6).Should().Be(4f); Easing.InQuad(4.0, 2, 6).Should().Be(3);
Easing.InOutQuad(5, 2, 6).Should().Be(5.5f); Easing.InQuad(5.0, 2, 6).Should().Be(4.25);
invalidTime = () => Easing.InOutQuad(7, 2, 6); CheckDoubleArguments(Easing.InQuad, Easing.InQuad);
invalidTime.Should().Throw<ArgumentException>(); }
Easing.InOutQuad(3.0, 2, 6).Should().Be(2.5); [Test]
Easing.InOutQuad(4.0, 2, 6).Should().Be(4); public void OutQuad()
Easing.InOutQuad(5.0, 2, 6).Should().Be(5.5); {
} Easing.OutQuad(0.25).Should().Be(0.4375);
Easing.OutQuad(0.5).Should().Be(0.75);
Easing.OutQuad(0.75).Should().Be(0.9375);
[Test] Easing.OutQuad(3.0, 2, 6).Should().Be(3.75);
public void OutInQuad() Easing.OutQuad(4.0, 2, 6).Should().Be(5);
{ Easing.OutQuad(5.0, 2, 6).Should().Be(5.75);
Easing.OutInQuad(0.25f).Should().Be(0.375f);
Easing.OutInQuad(0.5f).Should().Be(0.5f);
Easing.OutInQuad(0.75f).Should().Be(0.625f);
Action invalidTime = () => Easing.OutInQuad(1.5f); CheckDoubleArguments(Easing.OutQuad, Easing.OutQuad);
invalidTime.Should().Throw<ArgumentException>(); }
Easing.OutInQuad(0.25).Should().Be(0.375); [Test]
Easing.OutInQuad(0.5).Should().Be(0.5); public void InOutQuad()
Easing.OutInQuad(0.75).Should().Be(0.625); {
Easing.InOutQuad(0.25).Should().Be(0.125);
Easing.InOutQuad(0.5).Should().Be(0.5);
Easing.InOutQuad(0.75).Should().Be(0.875);
invalidTime = () => Easing.OutInQuad(1.5); Easing.InOutQuad(3.0, 2, 6).Should().Be(2.5);
invalidTime.Should().Throw<ArgumentException>(); Easing.InOutQuad(4.0, 2, 6).Should().Be(4);
Easing.InOutQuad(5.0, 2, 6).Should().Be(5.5);
Easing.OutInQuad(3, 2, 6).Should().Be(3.5f); CheckDoubleArguments(Easing.InOutQuad, Easing.InOutQuad);
Easing.OutInQuad(4, 2, 6).Should().Be(4f); }
Easing.OutInQuad(5, 2, 6).Should().Be(4.5f);
invalidTime = () => Easing.OutInQuad(7, 2, 6); [Test]
invalidTime.Should().Throw<ArgumentException>(); public void OutInQuad()
{
Easing.OutInQuad(0.25).Should().Be(0.375);
Easing.OutInQuad(0.5).Should().Be(0.5);
Easing.OutInQuad(0.75).Should().Be(0.625);
Easing.OutInQuad(3.0, 2, 6).Should().Be(3.5); Easing.OutInQuad(3.0, 2, 6).Should().Be(3.5);
Easing.OutInQuad(4.0, 2, 6).Should().Be(4); Easing.OutInQuad(4.0, 2, 6).Should().Be(4);
Easing.OutInQuad(5.0, 2, 6).Should().Be(4.5); Easing.OutInQuad(5.0, 2, 6).Should().Be(4.5);
}
[Test] CheckDoubleArguments(Easing.OutInQuad, Easing.OutInQuad);
public void InCubic() }
{
Easing.InCubic(0.25f).Should().Be(0.015625f);
Easing.InCubic(0.5f).Should().Be(0.125f);
Easing.InCubic(0.75f).Should().Be(0.421875f);
Action invalidTime = () => Easing.InCubic(1.5f); [Test]
invalidTime.Should().Throw<ArgumentException>(); public void InCubic()
{
Easing.InCubic(0.25).Should().Be(0.015625);
Easing.InCubic(0.5).Should().Be(0.125);
Easing.InCubic(0.75).Should().Be(0.421875);
Easing.InCubic(0.25).Should().Be(0.015625); Easing.InCubic(3.0, 2, 6).Should().Be(2.0625);
Easing.InCubic(0.5).Should().Be(0.125); Easing.InCubic(4.0, 2, 6).Should().Be(2.5);
Easing.InCubic(0.75).Should().Be(0.421875); Easing.InCubic(5.0, 2, 6).Should().Be(3.6875);
invalidTime = () => Easing.InCubic(1.5); CheckDoubleArguments(Easing.InCubic, Easing.InCubic);
invalidTime.Should().Throw<ArgumentException>(); }
Easing.InCubic(3, 2, 6).Should().Be(2.0625f); [Test]
Easing.InCubic(4, 2, 6).Should().Be(2.5f); public void OutCubic()
Easing.InCubic(5, 2, 6).Should().Be(3.6875f); {
Easing.OutCubic(0.25).Should().Be(0.578125);
Easing.OutCubic(0.5).Should().Be(0.875);
Easing.OutCubic(0.75).Should().Be(0.984375);
invalidTime = () => Easing.InCubic(7, 2, 6); Easing.OutCubic(3.0, 2, 6).Should().Be(4.3125);
invalidTime.Should().Throw<ArgumentException>(); Easing.OutCubic(4.0, 2, 6).Should().Be(5.5);
Easing.OutCubic(5.0, 2, 6).Should().Be(5.9375);
Easing.InCubic(3.0, 2, 6).Should().Be(2.0625); CheckDoubleArguments(Easing.OutCubic, Easing.OutCubic);
Easing.InCubic(4.0, 2, 6).Should().Be(2.5); }
Easing.InCubic(5.0, 2, 6).Should().Be(3.6875);
}
[Test]
public void OutCubic()
{
Easing.OutCubic(0.25f).Should().Be(0.578125f);
Easing.OutCubic(0.5f).Should().Be(0.875f);
Easing.OutCubic(0.75f).Should().Be(0.984375f);
Action invalidTime = () => Easing.OutCubic(1.5);
invalidTime.Should().Throw<ArgumentException>();
Easing.OutCubic(0.25).Should().Be(0.578125);
Easing.OutCubic(0.5).Should().Be(0.875);
Easing.OutCubic(0.75).Should().Be(0.984375);
invalidTime = () => Easing.OutCubic(1.5);
invalidTime.Should().Throw<ArgumentException>();
Easing.OutCubic(3, 2, 6).Should().Be(4.3125f);
Easing.OutCubic(4, 2, 6).Should().Be(5.5f);
Easing.OutCubic(5, 2, 6).Should().Be(5.9375f);
invalidTime = () => Easing.OutCubic(7, 2, 6);
invalidTime.Should().Throw<ArgumentException>();
Easing.OutCubic(3.0, 2, 6).Should().Be(4.3125);
Easing.OutCubic(4.0, 2, 6).Should().Be(5.5);
Easing.OutCubic(5.0, 2, 6).Should().Be(5.9375);
} }
} }
} }