// 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 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); }