コード例 #1
0
ファイル: MathTest.cs プロジェクト: pheney/PLibUnitTests
        public void ImpactForceInNewtons_ReturnsCorrectValue()
        {
            //  prereq
            Approx_Works();

            //  arrange
            float mass      = 10;    //  kg
            float speed     = 50;    //  m/s
            float lossRatio = 0.5f;  //  50% speed energy loss
            float deltaTime = 1f / 60;

            //  act
            float force    = PMath.ImpactForceInNewtons(mass, speed, lossRatio, deltaTime);
            float expected = mass * speed * lossRatio / deltaTime;

            //  assert
            Assert.IsTrue(PMath.Approx(expected, force), TestHelper.ShowVariables(expected, force));
        }