public void OK() { var mc = new MyClass(10); RunTest(AnyValue.IsValid, () => mc.Method(), SmartAssert.Within(100)); }
// ReSharper disable once InconsistentNaming public void Context_OK() { var mc = new MyClass(300); RunTest(AnyValue.IsValid, ctx => mc.Method(ctx.SetHandle), SmartAssert.Within(100), SmartAssert.WaitContextHandle(1000)); Assert.IsTrue(mc.Done); Assert.IsNull(mc.Exception); }
// ReSharper disable once InconsistentNaming public void OK() { var handle = new AutoResetEvent(false); var mc = new MyClass(300); RunTest(AnyValue.IsValid, () => mc.Method(() => handle.Set()), SmartAssert.Within(100), SmartAssert.Wait(handle, 1000)); Assert.IsTrue(mc.Done); Assert.IsNull(mc.Exception); }
public void NegativeTimeout() { var exception = Assert.Catch <BadTestException>(() => { var mc = new MyClass(100); RunTest(AnyValue.IsValid, () => mc.Method(), SmartAssert.Within(-90)); }); Assert.AreEqual(@"BAD TEST: Time should be strictly positive, but was -90ms", exception.Message); }
public void Fail() { var exception = Assert.Catch <SmartTestException>(() => { var mc = new MyClass(100); RunTest(AnyValue.IsValid, () => mc.Method(), SmartAssert.Within(90)); }); StringAssert.IsMatch(@"Should be less than 90ms, but was \d+ms", exception.Message); }
public void Context_Timeout() { var mc = new MyClass(300); var exception = Assert.Catch <SmartTestException>(() => RunTest(AnyValue.IsValid, ctx => mc.Method(ctx.SetHandle), SmartAssert.Within(100), SmartAssert.WaitContextHandle(200)) ); Assert.IsFalse(mc.Done); Assert.IsNull(mc.Exception); Assert.AreEqual("Timeout reached (200ms)", exception.Message); }
public void Exception() { var mc = new MyClass(300, true); var handle = new AutoResetEvent(false); var exception = Assert.Catch <SmartTestException>(() => RunTest(AnyValue.IsValid, () => mc.Method(() => handle.Set()), SmartAssert.Within(100), SmartAssert.Wait(handle, 200)) ); Assert.IsFalse(mc.Done); Assert.AreEqual("OOPS!", mc.Exception.Message); Assert.AreEqual("Timeout reached (200ms)", exception.Message); }
public void NoContextHandle() { var handle = new AutoResetEvent(false); var mc = new MyClass(300); var exception = Assert.Catch <InconclusiveException>(() => RunTest(AnyValue.IsValid, ctx => mc.Method(ctx.SetHandle), SmartAssert.Within(100), SmartAssert.Wait(handle, 500)) ); Assert.IsTrue(mc.Done); Assert.AreEqual("BAD TEST: ActContext.SetHandle called, but specified handle expected", mc.Exception.Message); Assert.AreEqual("BAD TEST: ActContext.SetHandle called, but specified handle expected", exception.Message); }
public void NoWaitHandle() { var handle = new AutoResetEvent(false); var mc = new MyClass(300); var exception = Assert.Catch <SmartTestException>(() => RunTest(AnyValue.IsValid, () => mc.Method(() => handle.Set()), SmartAssert.Within(100), SmartAssert.WaitContextHandle(500)) ); Assert.IsTrue(mc.Done); Assert.IsNull(mc.Exception); Assert.AreEqual("Timeout reached (500ms)", exception.Message); }