restructure tests
parent
606fed9878
commit
251391216f
231
Test/Easing.cs
231
Test/Easing.cs
|
@ -7,6 +7,26 @@ using System;
|
||||||
namespace Test
|
namespace Test
|
||||||
{
|
{
|
||||||
public class EasingTests
|
public class EasingTests
|
||||||
|
{
|
||||||
|
public static void CheckFloatArguments(Func<float, float> easingNormalizedFunction, Func<float, float, float, float> easingRangeFunction)
|
||||||
|
{
|
||||||
|
Action invalidTime = () => easingNormalizedFunction(1.5f);
|
||||||
|
invalidTime.Should().Throw<ArgumentException>();
|
||||||
|
|
||||||
|
invalidTime = () => easingRangeFunction(7, 2, 6);
|
||||||
|
invalidTime.Should().Throw<ArgumentException>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void CheckDoubleArguments(Func<double, double> easingNormalizedFunction, Func<double, double, double, double> easingRangeFunction)
|
||||||
|
{
|
||||||
|
Action invalidTime = () => easingNormalizedFunction(1.5);
|
||||||
|
invalidTime.Should().Throw<ArgumentException>();
|
||||||
|
|
||||||
|
invalidTime = () => easingRangeFunction(7, 2, 6);
|
||||||
|
invalidTime.Should().Throw<ArgumentException>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class FloatTests
|
||||||
{
|
{
|
||||||
[Test]
|
[Test]
|
||||||
public void Linear()
|
public void Linear()
|
||||||
|
@ -15,26 +35,11 @@ namespace Test
|
||||||
Easing.Linear(0.5f).Should().Be(0.5f);
|
Easing.Linear(0.5f).Should().Be(0.5f);
|
||||||
Easing.Linear(0.75f).Should().Be(0.75f);
|
Easing.Linear(0.75f).Should().Be(0.75f);
|
||||||
|
|
||||||
Action invalidTime = () => Easing.Linear(1.5f);
|
|
||||||
invalidTime.Should().Throw<ArgumentException>();
|
|
||||||
|
|
||||||
Easing.Linear(0.25).Should().Be(0.25);
|
|
||||||
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>();
|
|
||||||
|
|
||||||
Easing.Linear(3, 2, 6).Should().Be(3f);
|
Easing.Linear(3, 2, 6).Should().Be(3f);
|
||||||
Easing.Linear(4, 2, 6).Should().Be(4f);
|
Easing.Linear(4, 2, 6).Should().Be(4f);
|
||||||
Easing.Linear(5, 2, 6).Should().Be(5f);
|
Easing.Linear(5, 2, 6).Should().Be(5f);
|
||||||
|
|
||||||
invalidTime = () => Easing.Linear(7, 2, 6);
|
CheckFloatArguments(Easing.Linear, Easing.Linear);
|
||||||
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]
|
[Test]
|
||||||
|
@ -44,26 +49,11 @@ namespace Test
|
||||||
Easing.InQuad(0.5f).Should().Be(0.25f);
|
Easing.InQuad(0.5f).Should().Be(0.25f);
|
||||||
Easing.InQuad(0.75f).Should().Be(0.5625f);
|
Easing.InQuad(0.75f).Should().Be(0.5625f);
|
||||||
|
|
||||||
Action invalidTime = () => Easing.InQuad(1.5f);
|
|
||||||
invalidTime.Should().Throw<ArgumentException>();
|
|
||||||
|
|
||||||
Easing.InQuad(0.25).Should().Be(0.0625);
|
|
||||||
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>();
|
|
||||||
|
|
||||||
Easing.InQuad(3, 2, 6).Should().Be(2.25f);
|
Easing.InQuad(3, 2, 6).Should().Be(2.25f);
|
||||||
Easing.InQuad(4, 2, 6).Should().Be(3f);
|
Easing.InQuad(4, 2, 6).Should().Be(3f);
|
||||||
Easing.InQuad(5, 2, 6).Should().Be(4.25f);
|
Easing.InQuad(5, 2, 6).Should().Be(4.25f);
|
||||||
|
|
||||||
invalidTime = () => Easing.InQuad(7, 2, 6);
|
CheckFloatArguments(Easing.InQuad, Easing.InQuad);
|
||||||
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]
|
[Test]
|
||||||
|
@ -73,26 +63,11 @@ namespace Test
|
||||||
Easing.OutQuad(0.5f).Should().Be(0.75f);
|
Easing.OutQuad(0.5f).Should().Be(0.75f);
|
||||||
Easing.OutQuad(0.75f).Should().Be(0.9375f);
|
Easing.OutQuad(0.75f).Should().Be(0.9375f);
|
||||||
|
|
||||||
Action invalidTime = () => Easing.OutQuad(1.5f);
|
|
||||||
invalidTime.Should().Throw<ArgumentException>();
|
|
||||||
|
|
||||||
Easing.OutQuad(0.25).Should().Be(0.4375);
|
|
||||||
Easing.OutQuad(0.5).Should().Be(0.75);
|
|
||||||
Easing.OutQuad(0.75).Should().Be(0.9375);
|
|
||||||
|
|
||||||
invalidTime = () => Easing.OutQuad(1.5);
|
|
||||||
invalidTime.Should().Throw<ArgumentException>();
|
|
||||||
|
|
||||||
Easing.OutQuad(3, 2, 6).Should().Be(3.75f);
|
Easing.OutQuad(3, 2, 6).Should().Be(3.75f);
|
||||||
Easing.OutQuad(4, 2, 6).Should().Be(5f);
|
Easing.OutQuad(4, 2, 6).Should().Be(5f);
|
||||||
Easing.OutQuad(5, 2, 6).Should().Be(5.75f);
|
Easing.OutQuad(5, 2, 6).Should().Be(5.75f);
|
||||||
|
|
||||||
invalidTime = () => Easing.OutQuad(7, 2, 6);
|
CheckFloatArguments(Easing.OutQuad, Easing.OutQuad);
|
||||||
invalidTime.Should().Throw<ArgumentException>();
|
|
||||||
|
|
||||||
Easing.OutQuad(3.0, 2, 6).Should().Be(3.75);
|
|
||||||
Easing.OutQuad(4.0, 2, 6).Should().Be(5);
|
|
||||||
Easing.OutQuad(5.0, 2, 6).Should().Be(5.75);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -102,26 +77,11 @@ namespace Test
|
||||||
Easing.InOutQuad(0.5f).Should().Be(0.5f);
|
Easing.InOutQuad(0.5f).Should().Be(0.5f);
|
||||||
Easing.InOutQuad(0.75f).Should().Be(0.875f);
|
Easing.InOutQuad(0.75f).Should().Be(0.875f);
|
||||||
|
|
||||||
Action invalidTime = () => Easing.InOutQuad(1.5f);
|
|
||||||
invalidTime.Should().Throw<ArgumentException>();
|
|
||||||
|
|
||||||
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.InOutQuad(1.5);
|
|
||||||
invalidTime.Should().Throw<ArgumentException>();
|
|
||||||
|
|
||||||
Easing.InOutQuad(3, 2, 6).Should().Be(2.5f);
|
Easing.InOutQuad(3, 2, 6).Should().Be(2.5f);
|
||||||
Easing.InOutQuad(4, 2, 6).Should().Be(4f);
|
Easing.InOutQuad(4, 2, 6).Should().Be(4f);
|
||||||
Easing.InOutQuad(5, 2, 6).Should().Be(5.5f);
|
Easing.InOutQuad(5, 2, 6).Should().Be(5.5f);
|
||||||
|
|
||||||
invalidTime = () => Easing.InOutQuad(7, 2, 6);
|
CheckFloatArguments(Easing.InOutQuad, Easing.InOutQuad);
|
||||||
invalidTime.Should().Throw<ArgumentException>();
|
|
||||||
|
|
||||||
Easing.InOutQuad(3.0, 2, 6).Should().Be(2.5);
|
|
||||||
Easing.InOutQuad(4.0, 2, 6).Should().Be(4);
|
|
||||||
Easing.InOutQuad(5.0, 2, 6).Should().Be(5.5);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -131,26 +91,11 @@ namespace Test
|
||||||
Easing.OutInQuad(0.5f).Should().Be(0.5f);
|
Easing.OutInQuad(0.5f).Should().Be(0.5f);
|
||||||
Easing.OutInQuad(0.75f).Should().Be(0.625f);
|
Easing.OutInQuad(0.75f).Should().Be(0.625f);
|
||||||
|
|
||||||
Action invalidTime = () => Easing.OutInQuad(1.5f);
|
|
||||||
invalidTime.Should().Throw<ArgumentException>();
|
|
||||||
|
|
||||||
Easing.OutInQuad(0.25).Should().Be(0.375);
|
|
||||||
Easing.OutInQuad(0.5).Should().Be(0.5);
|
|
||||||
Easing.OutInQuad(0.75).Should().Be(0.625);
|
|
||||||
|
|
||||||
invalidTime = () => Easing.OutInQuad(1.5);
|
|
||||||
invalidTime.Should().Throw<ArgumentException>();
|
|
||||||
|
|
||||||
Easing.OutInQuad(3, 2, 6).Should().Be(3.5f);
|
Easing.OutInQuad(3, 2, 6).Should().Be(3.5f);
|
||||||
Easing.OutInQuad(4, 2, 6).Should().Be(4f);
|
Easing.OutInQuad(4, 2, 6).Should().Be(4f);
|
||||||
Easing.OutInQuad(5, 2, 6).Should().Be(4.5f);
|
Easing.OutInQuad(5, 2, 6).Should().Be(4.5f);
|
||||||
|
|
||||||
invalidTime = () => Easing.OutInQuad(7, 2, 6);
|
CheckFloatArguments(Easing.OutInQuad, Easing.OutInQuad);
|
||||||
invalidTime.Should().Throw<ArgumentException>();
|
|
||||||
|
|
||||||
Easing.OutInQuad(3.0, 2, 6).Should().Be(3.5);
|
|
||||||
Easing.OutInQuad(4.0, 2, 6).Should().Be(4);
|
|
||||||
Easing.OutInQuad(5.0, 2, 6).Should().Be(4.5);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -160,26 +105,11 @@ namespace Test
|
||||||
Easing.InCubic(0.5f).Should().Be(0.125f);
|
Easing.InCubic(0.5f).Should().Be(0.125f);
|
||||||
Easing.InCubic(0.75f).Should().Be(0.421875f);
|
Easing.InCubic(0.75f).Should().Be(0.421875f);
|
||||||
|
|
||||||
Action invalidTime = () => Easing.InCubic(1.5f);
|
|
||||||
invalidTime.Should().Throw<ArgumentException>();
|
|
||||||
|
|
||||||
Easing.InCubic(0.25).Should().Be(0.015625);
|
|
||||||
Easing.InCubic(0.5).Should().Be(0.125);
|
|
||||||
Easing.InCubic(0.75).Should().Be(0.421875);
|
|
||||||
|
|
||||||
invalidTime = () => Easing.InCubic(1.5);
|
|
||||||
invalidTime.Should().Throw<ArgumentException>();
|
|
||||||
|
|
||||||
Easing.InCubic(3, 2, 6).Should().Be(2.0625f);
|
Easing.InCubic(3, 2, 6).Should().Be(2.0625f);
|
||||||
Easing.InCubic(4, 2, 6).Should().Be(2.5f);
|
Easing.InCubic(4, 2, 6).Should().Be(2.5f);
|
||||||
Easing.InCubic(5, 2, 6).Should().Be(3.6875f);
|
Easing.InCubic(5, 2, 6).Should().Be(3.6875f);
|
||||||
|
|
||||||
invalidTime = () => Easing.InCubic(7, 2, 6);
|
CheckFloatArguments(Easing.InCubic, Easing.InCubic);
|
||||||
invalidTime.Should().Throw<ArgumentException>();
|
|
||||||
|
|
||||||
Easing.InCubic(3.0, 2, 6).Should().Be(2.0625);
|
|
||||||
Easing.InCubic(4.0, 2, 6).Should().Be(2.5);
|
|
||||||
Easing.InCubic(5.0, 2, 6).Should().Be(3.6875);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -189,26 +119,111 @@ namespace Test
|
||||||
Easing.OutCubic(0.5f).Should().Be(0.875f);
|
Easing.OutCubic(0.5f).Should().Be(0.875f);
|
||||||
Easing.OutCubic(0.75f).Should().Be(0.984375f);
|
Easing.OutCubic(0.75f).Should().Be(0.984375f);
|
||||||
|
|
||||||
Action invalidTime = () => Easing.OutCubic(1.5);
|
Easing.OutCubic(3, 2, 6).Should().Be(4.3125f);
|
||||||
invalidTime.Should().Throw<ArgumentException>();
|
Easing.OutCubic(4, 2, 6).Should().Be(5.5f);
|
||||||
|
Easing.OutCubic(5, 2, 6).Should().Be(5.9375f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class DoubleTests
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void Linear()
|
||||||
|
{
|
||||||
|
Easing.Linear(0.25).Should().Be(0.25);
|
||||||
|
Easing.Linear(0.5).Should().Be(0.5);
|
||||||
|
Easing.Linear(0.75).Should().Be(0.75);
|
||||||
|
|
||||||
|
Easing.Linear(3.0, 2, 6).Should().Be(3);
|
||||||
|
Easing.Linear(4.0, 2, 6).Should().Be(4);
|
||||||
|
Easing.Linear(5.0, 2, 6).Should().Be(5);
|
||||||
|
|
||||||
|
CheckDoubleArguments(Easing.Linear, Easing.Linear);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
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.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);
|
||||||
|
|
||||||
|
CheckDoubleArguments(Easing.InQuad, Easing.InQuad);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void OutQuad()
|
||||||
|
{
|
||||||
|
Easing.OutQuad(0.25).Should().Be(0.4375);
|
||||||
|
Easing.OutQuad(0.5).Should().Be(0.75);
|
||||||
|
Easing.OutQuad(0.75).Should().Be(0.9375);
|
||||||
|
|
||||||
|
Easing.OutQuad(3.0, 2, 6).Should().Be(3.75);
|
||||||
|
Easing.OutQuad(4.0, 2, 6).Should().Be(5);
|
||||||
|
Easing.OutQuad(5.0, 2, 6).Should().Be(5.75);
|
||||||
|
|
||||||
|
CheckDoubleArguments(Easing.OutQuad, Easing.OutQuad);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void InOutQuad()
|
||||||
|
{
|
||||||
|
Easing.InOutQuad(0.25).Should().Be(0.125);
|
||||||
|
Easing.InOutQuad(0.5).Should().Be(0.5);
|
||||||
|
Easing.InOutQuad(0.75).Should().Be(0.875);
|
||||||
|
|
||||||
|
Easing.InOutQuad(3.0, 2, 6).Should().Be(2.5);
|
||||||
|
Easing.InOutQuad(4.0, 2, 6).Should().Be(4);
|
||||||
|
Easing.InOutQuad(5.0, 2, 6).Should().Be(5.5);
|
||||||
|
|
||||||
|
CheckDoubleArguments(Easing.InOutQuad, Easing.InOutQuad);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
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(4.0, 2, 6).Should().Be(4);
|
||||||
|
Easing.OutInQuad(5.0, 2, 6).Should().Be(4.5);
|
||||||
|
|
||||||
|
CheckDoubleArguments(Easing.OutInQuad, Easing.OutInQuad);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
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(3.0, 2, 6).Should().Be(2.0625);
|
||||||
|
Easing.InCubic(4.0, 2, 6).Should().Be(2.5);
|
||||||
|
Easing.InCubic(5.0, 2, 6).Should().Be(3.6875);
|
||||||
|
|
||||||
|
CheckDoubleArguments(Easing.InCubic, Easing.InCubic);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void OutCubic()
|
||||||
|
{
|
||||||
Easing.OutCubic(0.25).Should().Be(0.578125);
|
Easing.OutCubic(0.25).Should().Be(0.578125);
|
||||||
Easing.OutCubic(0.5).Should().Be(0.875);
|
Easing.OutCubic(0.5).Should().Be(0.875);
|
||||||
Easing.OutCubic(0.75).Should().Be(0.984375);
|
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(3.0, 2, 6).Should().Be(4.3125);
|
||||||
Easing.OutCubic(4.0, 2, 6).Should().Be(5.5);
|
Easing.OutCubic(4.0, 2, 6).Should().Be(5.5);
|
||||||
Easing.OutCubic(5.0, 2, 6).Should().Be(5.9375);
|
Easing.OutCubic(5.0, 2, 6).Should().Be(5.9375);
|
||||||
|
|
||||||
|
CheckDoubleArguments(Easing.OutCubic, Easing.OutCubic);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue