예제 #1
0
        public void It_checks_all_of_the_states_in_a_robust_query_expecting_true()
        {
            bool queriedState1 = false;
            bool queriedState2 = false;
            var state1 = new State(new LambdaQuery<bool>(() =>
                                       {
                                           queriedState1 = true;
                                           return false;
                                       }));
            var state2 = new State(new LambdaQuery<bool>(() =>
                                       {
                                           queriedState2 = true;
                                           return true;
                                       }));
            var state3 = new State(new LambdaQuery<bool>(() => true));
            state3.CheckCondition();

            var robustWrapper = new SpyRobustWrapper();
            robustWrapper.StubQueryResult(true, true);

            var session = BuildSession(robustWrapper);

            Assert.That(session.FindState(new [] {state1, state2, state3}), Is.SameAs(state3));

            Assert.IsFalse(queriedState1);
            Assert.IsFalse(queriedState2);

            var query = robustWrapper.QueriesRan<bool>().Single();
            var queryResult = query.Run();
            Assert.IsTrue(queryResult);

            Assert.IsTrue(queriedState1);
            Assert.IsTrue(queriedState2);
        }
        public void It_uses_individual_timeout_for_query_leaving()
        {
            var individualTimeout = TimeSpan.FromSeconds(321);

            var spyRobustWrapper = new SpyRobustWrapper();
            var session = new Session(null, spyRobustWrapper, null, null, null);

            session.FindLink("bob").WithTimeout(individualTimeout).Now();

            Assert.That(spyRobustWrapper.QueriesRan<Element>().Single().Timeout, Is.EqualTo(individualTimeout));
        }
예제 #3
0
        public void It_uses_individual_timeout_for_query_leaving()
        {
            var individualTimeout = TimeSpan.FromSeconds(321);

            var spyRobustWrapper = new SpyRobustWrapper();
            var session          = new Session(null, spyRobustWrapper, null, null, null);

            session.FindLink("bob").WithTimeout(individualTimeout).Now();

            Assert.That(spyRobustWrapper.QueriesRan <Element>().Single().Timeout, Is.EqualTo(individualTimeout));
        }
예제 #4
0
        public void It_checks_all_of_the_states_in_a_robust_query_expecting_true()
        {
            bool queriedState1 = false;
            bool queriedState2 = false;
            var  state1        = new State(new LambdaQuery <bool>(() =>
            {
                queriedState1 = true;
                return(false);
            }));
            var state2 = new State(new LambdaQuery <bool>(() =>
            {
                queriedState2 = true;
                return(true);
            }));
            var state3 = new State(new LambdaQuery <bool>(() => true));

            state3.CheckCondition();

            var robustWrapper = new SpyRobustWrapper();

            robustWrapper.StubQueryResult(true, true);

            var session = BuildSession(robustWrapper);

            Assert.That(session.FindState(new [] { state1, state2, state3 }), Is.SameAs(state3));

            Assert.IsFalse(queriedState1);
            Assert.IsFalse(queriedState2);

            var query       = robustWrapper.QueriesRan <bool>().Single();
            var queryResult = query.Run();

            Assert.IsTrue(queryResult);

            Assert.IsTrue(queriedState1);
            Assert.IsTrue(queriedState2);
        }
예제 #5
0
        protected T RunQueryAndCheckTiming <T>(TimeSpan timeout)
        {
            var query = spyRobustWrapper.QueriesRan <T>().Single();

            return(RunQueryAndCheckTiming(query, timeout));
        }