public void GetTotalSeconds() { var instrumentation = new Instrumentation(); instrumentation.Start(); Thread.Sleep(750); Assert.AreEqual(1, instrumentation.GetElapsedTime()); }
public void GetTotalSeconds() { var instrumentation = new Instrumentation(); instrumentation.Start(); Thread.Sleep(750); Assert.AreEqual(1, instrumentation.GetElapsedTime()); //passes bacause GetElapsedTime() rounds to whole seconds }
public void GetPreciseElapsedTime() { var instrumentation = new Instrumentation(); instrumentation.Start(); Thread.Sleep(750); var elapsed = instrumentation.GetPreciseElapsedTime(); Assert.IsTrue(0.75 <= elapsed && elapsed <= 0.78); }
public void GetPreciseElapsedTime() { var instrumentation = new Instrumentation(); instrumentation.Start(); Thread.Sleep(750); var elapsed = instrumentation.GetPreciseElapsedTime(); //Assert.IsTrue(elapsed >= 0.75 && elapsed < 0.751); //fails because using reflection (in GetPreciseElapsedTime) takes time. Assert.IsTrue(elapsed >= 0.75 && elapsed < 0.78);//passes because we broadened the range. //Could have fixed by taking the ending time before using reflection istead, but this example shows the limitations of reflection. }
public void GetPreciseElapseTimeTest() { //-- Arrange Instrumentation instrumentation = new Instrumentation(); //-- Act instrumentation.Start(); Thread.Sleep(750); double elapsedTime = instrumentation.GetPreciseElapsedTime(); Debug.Write(elapsedTime); //-- Assert Assert.IsTrue(elapsedTime >= 0.75 && elapsedTime < 0.780); }
public void StartTest() { //-- Arrange Instrumentation instrumentation = new Instrumentation(); //-- Act instrumentation.Start(); Thread.Sleep(750); int actual = instrumentation.GetElapsedTime(); Debug.Write(actual); //-- Assert Assert.AreEqual(1, actual); }