Ejemplo n.º 1
0
        public void Record_call_should_ensure_all_previous_steps_completed()
        {
            using (var loop = new Loop(Times.Once()))
            {
                var stepBefore = loop.CreateStep("", Times.AtMostOnce());

                Loop nested;
                Step stepNested;

                using (nested = loop.CreateLoop(Times.Once()))
                {
                    stepNested = loop.CreateStep("", Times.Once());
                }

                var stepAfter = loop.CreateStep("", Times.Once());

                loop.RecordCall(stepNested);
                Assert.That(stepBefore.Complete, Is.True);
                Assert.That(loop.Complete, Is.False);
                Assert.That(stepNested.Complete, Is.False);
                Assert.That(stepAfter.Complete, Is.False);

                loop.RecordCall(stepAfter);

                Assert.That(stepBefore.Complete, Is.True);
                Assert.That(nested.Complete, Is.True);
                Assert.That(stepNested.Complete, Is.True);
                Assert.That(stepAfter.Complete, Is.False);
            }
        }
Ejemplo n.º 2
0
        public void RecordCall_should_throw_if_steps_called_out_of_sequence()
        {
            using (var loop = new Loop(Times.Once()))
            {
                loop.CreateStep("", Times.Once());
                var step = loop.CreateStep("", Times.Once());

                Assert.Throws <SequenceException>(() => loop.RecordCall(step));
            }
        }
Ejemplo n.º 3
0
        public void RecordCall_should_throw_when_loop_count_exceeded()
        {
            using (var loop = new Loop(Times.Exactly(2)))
            {
                var step1 = loop.CreateStep("", Times.Once());
                var step2 = loop.CreateStep("", Times.Once());

                loop.RecordCall(step1); loop.RecordCall(step2);
                loop.RecordCall(step1); loop.RecordCall(step2);

                Assert.Throws <SequenceException>(() => loop.RecordCall(step1));
            }
        }
Ejemplo n.º 4
0
        public void A_new_step_should_be_added_directly_if_it_contains_no_child_loops()
        {
            using (var loop = new Loop(Times.Once()))
            {
                var step = loop.CreateStep("", Times.Once());

                Assert.That(loop.Steps.Contains(step));
            }
        }
Ejemplo n.º 5
0
        public void A_new_step_should_be_added_directly_if_it_contains_no_child_loops()
        {
            using (var loop = new Loop(Times.Once()))
            {
                var step = loop.CreateStep("", Times.Once());

                Assert.That(loop.Steps.Contains(step));
            }
        }
Ejemplo n.º 6
0
        public void A_new_step_should_be_added_to_most_recently_created_child_loop()
        {
            using (var loop = new Loop(Times.Once()))
            {
                using (loop.CreateLoop(Times.Once()))
                {
                    using (loop.CreateLoop(Times.Once()))
                    {
                    }

                    using (var child2 = loop.CreateLoop(Times.Once()))
                    {
                        var step2 = loop.CreateStep("", Times.Once());
                        Assert.That(child2.Steps.Contains(step2));

                        using (var child3 = loop.CreateLoop(Times.Once()))
                        {
                            var step3 = loop.CreateStep("", Times.Once());
                            Assert.That(child3.Steps.Contains(step3));
                        }
                    }
                }
            }
        }
Ejemplo n.º 7
0
        public void A_new_step_should_be_added_to_most_recently_created_child_loop()
        {
            using (var loop = new Loop(Times.Once()))
            {
                using (loop.CreateLoop(Times.Once()))
                {
                    using (loop.CreateLoop(Times.Once()))
                    {
                    }

                    using (var child2 = loop.CreateLoop(Times.Once()))
                    {
                        var step2 = loop.CreateStep("", Times.Once());
                        Assert.That(child2.Steps.Contains(step2));

                        using (var child3 = loop.CreateLoop(Times.Once()))
                        {
                            var step3 = loop.CreateStep("", Times.Once());
                            Assert.That(child3.Steps.Contains(step3));
                        }
                    }
                }
            }
        }
Ejemplo n.º 8
0
        public void Record_call_should_ensure_all_previous_steps_completed()
        {
            using (var loop = new Loop(Times.Once()))
            {
                var stepBefore = loop.CreateStep("", Times.AtMostOnce());

                Loop nested;
                Step stepNested;

                using (nested = loop.CreateLoop(Times.Once()))
                {
                    stepNested = loop.CreateStep("", Times.Once());
                }

                var stepAfter = loop.CreateStep("", Times.Once());

                loop.RecordCall(stepNested);
                Assert.That(stepBefore.Complete, Is.True);
                Assert.That(loop.Complete, Is.False);
                Assert.That(stepNested.Complete, Is.False);
                Assert.That(stepAfter.Complete, Is.False);

                loop.RecordCall(stepAfter);

                Assert.That(stepBefore.Complete, Is.True);
                Assert.That(nested.Complete, Is.True);
                Assert.That(stepNested.Complete, Is.True);
                Assert.That(stepAfter.Complete, Is.False);
            }
        }
Ejemplo n.º 9
0
        public void RecordCall_should_throw_when_step_count_exceeded()
        {
            using (var loop = new Loop(Times.Once()))
            {
                var step = loop.CreateStep("", Times.Exactly(2));

                loop.RecordCall(step);
                loop.RecordCall(step);

                Assert.Throws<SequenceException>(() => loop.RecordCall(step));
            }
        }
Ejemplo n.º 10
0
        public void RecordCall_should_throw_when_child_loop_count_exceeded()
        {
            using (var loop = new Loop(Times.Once()))
            {
                Step step1;
                Step step2;

                using (loop.CreateLoop(Times.Exactly(2)))
                {
                    step1 = loop.CreateStep("", Times.Once());
                    step2 = loop.CreateStep("", Times.Once());
                }

                loop.RecordCall(step1); loop.RecordCall(step2);
                loop.RecordCall(step1); loop.RecordCall(step2);

                Assert.Throws<SequenceException>(() => loop.RecordCall(step1));
            }
        }
Ejemplo n.º 11
0
        public void RecordCall_should_throw_if_steps_called_out_of_sequence()
        {
            using (var loop = new Loop(Times.Once()))
            {
                loop.CreateStep("", Times.Once());
                var step = loop.CreateStep("", Times.Once());

                Assert.Throws<SequenceException>(() => loop.RecordCall(step));
            }
        }