public void Long_Running_Test() { string hash; const int iterations = 1000; var sw= new Stopwatch(); sw.Start(); for (var i=0; i < iterations; i++) { hash = LowPasswordHasher.HashPassword(Constants.SecurePassword); } sw.Stop(); var low = sw.ElapsedMilliseconds/iterations; sw.Reset(); sw.Start(); for (var i = 0; i < iterations; i++) { hash = MediumPasswordHasher.HashPassword(Constants.SecurePassword); } sw.Stop(); var medium = sw.ElapsedMilliseconds / iterations; sw.Reset(); sw.Start(); for (var i = 0; i < iterations; i++) { hash = HighPasswordHasher.HashPassword(Constants.SecurePassword); } sw.Stop(); var high = sw.ElapsedMilliseconds / iterations; Assert.That(high >medium); }
public void TestStart() { var watch = new Stopwatch(); Assert.That(watch.IsRunning, Is.False); Assert.That(watch.ElapsedMilliseconds, Is.EqualTo(0)); watch.Start(); Delay(DELAY); Assert.That(watch.IsRunning, Is.True); Assert.That(watch.ElapsedMilliseconds, Is.EqualTo(DELAY).Within(TOLERANCE).Percent); }
public void TestStart() { var watch = new Stopwatch(); Assert.That(watch.IsRunning, Is.False); Assert.That(watch.ElapsedMilliseconds, Is.EqualTo(0)); watch.Start(); Thread.Sleep(SLEEP); Assert.That(watch.IsRunning, Is.True); Assert.That(watch.ElapsedMilliseconds, Is.GreaterThanOrEqualTo(MIN)); Assert.That(watch.ElapsedMilliseconds, Is.LessThan(MAX)); }