Пример #1
0
        public void WaitUntilRetryTimeoutCompletes()
        {
            var result = GenericWait.WaitUntilTimeout(() => true, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(1));

            Assert.IsTrue(result);
            result = GenericWait.WaitUntilTimeout(() => false, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(1));
            Assert.IsFalse(result);
        }
Пример #2
0
        public void WaitUntilTimeoutReturnsTrue()
        {
            var result = GenericWait.WaitUntilTimeout(
                () => true,
                TimeSpan.FromSeconds(1),
                TimeSpan.FromSeconds(2),
                false);

            Assert.IsTrue(result, "Expected Wait to return true");
        }
Пример #3
0
        public void WaitUntilTimeoutReturnsString()
        {
            var str    = "my string";
            var result = GenericWait.WaitUntilTimeout(
                () => str,
                TimeSpan.FromMilliseconds(500),
                TimeSpan.FromSeconds(1));

            Assert.AreEqual(str, result, "Wait result does not match the expected result of the method");
        }
Пример #4
0
        public void WaitUntilTimeoutReturnsStringWithArgument()
        {
            var str    = "my string";
            var result = GenericWait.WaitUntilTimeout(
                (a) => a,
                TimeSpan.FromSeconds(1),
                TimeSpan.FromSeconds(2),
                str);

            Assert.AreEqual(str, result, "Passed argument and result do not match");
        }
Пример #5
0
        public void WaitUntilTimeoutArgumentsTrue()
        {
            var str    = "my string";
            var result = GenericWait.WaitUntilTimeout(
                (a) => true,
                TimeSpan.FromMilliseconds(333),
                TimeSpan.FromSeconds(1),
                false,
                str);

            Assert.IsTrue(result, "Wait returned incorrect value");
        }
Пример #6
0
        public void WaitUntilTimeoutThrowsTimeoutException()
        {
            GenericWait.WaitUntilTimeout(() =>
            {
                Thread.Sleep(TimeSpan.FromSeconds(10));
                return("my string");
            },
                                         TimeSpan.FromSeconds(1),
                                         TimeSpan.FromSeconds(2));

            Assert.Fail();
        }
Пример #7
0
        public void WaitUntilTimeoutArgumentsThrowsException()
        {
            var str = "my string";

            GenericWait.WaitUntilTimeout(
                (a) =>
            {
                throw new Exception("This method didn't work");
            },
                TimeSpan.FromSeconds(1),
                TimeSpan.FromSeconds(2),
                true,
                str);

            Assert.Fail("Method should have thrown an exception");
        }
Пример #8
0
        public void WaitUntilTimeoutReturnsStringWithArgumentTimeoutException()
        {
            var str = "my string";

            GenericWait.WaitUntilTimeout(
                (a) =>
            {
                Thread.Sleep(TimeSpan.FromSeconds(10));
                return(a);
            },
                TimeSpan.FromSeconds(1),
                TimeSpan.FromSeconds(2),
                str);

            Assert.Fail("Method should have thrown an exception");
        }
Пример #9
0
        public void WaitUntilRetryTimeoutTimeoutBeforeMethodCompletion()
        {
            var stopwatch = Stopwatch.StartNew();
            var result    = GenericWait.WaitUntilTimeout(() =>
            {
                Thread.Sleep(TimeSpan.FromSeconds(10));
                return(true);
            },
                                                         TimeSpan.FromSeconds(1),
                                                         TimeSpan.FromSeconds(2),
                                                         false);

            stopwatch.Stop();
            Assert.IsFalse(result);
            Assert.IsTrue(stopwatch.Elapsed < TimeSpan.FromSeconds(10));
        }