using System; using System.Collections.Generic; using System.Linq; using System.Text; using UnitTestSharp; using Azimuth.ODE; namespace Azimuth.UnitTests.ODE { public class IntegratorsTests : TestFixture { public void TODO() { TODO("Test out cold and warm start integrators."); } public class IntegrationTypes : TestFixture { public void SUVAT_Test() { Scalar pos = 0; Scalar vel = 1; Scalar accel = -2; Integrators.SUVAT(2.0, ref pos, vel, accel); CheckEqual(-2, pos); } public void ExplicitEuler_Test() { Scalar pos = 0; Scalar vel = 10; Integrators.ExplicitEuler(2.0, ref pos, vel); CheckEqual(20, pos); } public void Verlet_Test() { Scalar pos = 1; Scalar oPos = -10; Scalar accel = 5; Integrators.Verlet(2.0, ref pos, oPos, accel); CheckEqual(2 + 10 + 20, pos); } public void TrapezoidMethod_Test() { Scalar pos = 0; Scalar vel = -5; Scalar velNew = 15; Integrators.TrapezoidMethod(2.0, ref pos, vel, velNew); CheckEqual(10, pos); } public void BeemansAlgorithmForPosition_Test() { Scalar pos = 0; Scalar vel = 2; Scalar accel = 3; Scalar oldAccel = 5; Integrators.BeemansAlgorithmForPosition(2.0, ref pos, vel, accel, oldAccel); CheckEqual(26.0 / 3.0, pos); } public void BeemansAlgorithmForVelocityExplicit_Test() { Scalar pos = 0; Scalar vel = 3; Scalar oldVel = -5; Integrators.BeemansAlgorithmForVelocityExplicit(2.0, ref pos, vel, oldVel); CheckEqual(26.0 / 3.0, pos); } public void BeemansAlgorithmForVelocityImplicit_Test() { Scalar pos = 1; Scalar vel = 3; Scalar oldVel = -5; Scalar newVel = 7; Integrators.BeemansAlgorithmForVelocityImplicit(2.0, ref pos, vel, oldVel, newVel); CheckEqual(37.0 / 3.0, pos); } } } }