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 When_query_returns_false_It_raises_an_exception() { var state1 = new State(new AlwaysSucceedsQuery <bool>(false, true, TimeSpan.Zero, SessionConfiguration.RetryInterval)); var state2 = new State(new AlwaysSucceedsQuery <bool>(false, true, TimeSpan.Zero, SessionConfiguration.RetryInterval)); var robustWrapper = new SpyRobustWrapper(); robustWrapper.StubQueryResult(true, false); var session = BuildSession(robustWrapper); try { session.FindState(state1, state2); Assert.Fail("Expected MissingHTMLException"); } catch (MissingHtmlException e) { Assert.That(e.Message, Is.EqualTo("None of the given states was reached within the configured timeout.")); } }
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 When_query_returns_false_It_raises_an_exception() { var state1 = new State(new AlwaysSucceedsQuery<bool>(false, true, TimeSpan.Zero, SessionConfiguration.RetryInterval)); var state2 = new State(new AlwaysSucceedsQuery<bool>(false, true, TimeSpan.Zero, SessionConfiguration.RetryInterval)); var robustWrapper = new SpyRobustWrapper(); robustWrapper.StubQueryResult(true, false); var session = BuildSession(robustWrapper); try { session.FindState(state1, state2); Assert.Fail("Expected MissingHTMLException"); } catch (MissingHtmlException e) { Assert.That(e.Message, Is.EqualTo("None of the given states was reached within the configured timeout.")); } }