Exemplo n.º 1
0
        public void OK()
        {
            var mc = new MyClass(10);

            RunTest(AnyValue.IsValid,
                    () => mc.Method(),
                    SmartAssert.Within(100));
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
        // 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);
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
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);
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
        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);
        }
Exemplo n.º 9
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);
        }