예제 #1
0
        // 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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }