public void MessageSendToMultipleKanKan(string message)
        {
            IKarassMessage karassMessage         = new KarassMessage();
            string         karassOneFrameMessage = string.Empty;

            bool KarassOneFrameSpy(string m)
            {
                karassOneFrameMessage = m;
                return(true);
            }

            FrameRequest karassOneFrameRequest = _mockFramesFactory.GetValidFrameRequest(KarassOneFrameSpy);

            string karassTwoFrameMessage = string.Empty;

            bool KarassTwoFrameSpy(string m)
            {
                karassTwoFrameMessage = m;
                return(true);
            }

            FrameRequest karassTwoFrameRequest = _mockFramesFactory.GetValidFrameRequest(KarassTwoFrameSpy);


            string karassThreeFrameMessage = string.Empty;

            bool KarassThreeFrameSpy(string m)
            {
                karassThreeFrameMessage = m;
                return(true);
            }

            FrameRequest karassThreeFrameRequest = _mockFramesFactory.GetValidFrameRequest(KarassThreeFrameSpy);


            KarassFactory karassFactory = new KarassFactory();

            Karass karassOne   = karassFactory.Get(new List <Action>(), new List <Action>(), new [] { karassOneFrameRequest });
            Karass karassTwo   = karassFactory.Get(new List <Action>(), new List <Action>(), new [] { karassTwoFrameRequest });
            Karass karassThree = karassFactory.Get(new List <Action>(), new List <Action>(), new [] { karassThreeFrameRequest });

            KanKanCore.KanKan kanKanOne   = new KanKanCore.KanKan(karassOne, _frameFactory, karassMessage);
            KanKanCore.KanKan kanKanTwo   = new KanKanCore.KanKan(karassTwo, _frameFactory, karassMessage);
            KanKanCore.KanKan kanKanThree = new KanKanCore.KanKan(karassThree, _frameFactory, karassMessage);

            karassMessage.SetMessage(message);

            kanKanOne.MoveNext();
            kanKanTwo.MoveNext();
            kanKanThree.MoveNext();

            Assert.True(karassOneFrameMessage == message);
            Assert.True(karassTwoFrameMessage == message);
            Assert.True(karassThreeFrameMessage == message);
        }
示例#2
0
                public void TeardownActionsAreCalled()
                {
                    bool teardownCalled = false;
                    bool frameCalled    = false;

                    bool FrameSpy(string message)
                    {
                        frameCalled = true;
                        return(true);
                    }

                    void TeardownSpy()
                    {
                        teardownCalled = true;
                    }

                    FrameRequest frameRequest = _mockFramesFactory.GetValidFrameRequest(FrameSpy);
                    Karass       karass       = _karassFactory.Get(
                        new List <List <Action> >(),
                        CreateActionListWith(TeardownSpy),
                        new List <FrameRequest[]>
                    {
                        new[]
                        {
                            frameRequest
                        }
                    });
                    KanKan kankan = new KanKan(karass, _frameFactory);

                    kankan.MoveNext();
                    Assert.True(frameCalled);
                    kankan.MoveNext();
                    Assert.True(teardownCalled);
                }
            public void ThenOnlyContainsFirstFrame()
            {
                FrameRequest frameOne   = _mockFramesFactory.GetInvalidFrameRequest();
                FrameRequest frameTwo   = _mockFramesFactory.GetInvalidFrameRequest();
                FrameRequest frameThree = _mockFramesFactory.GetInvalidFrameRequest();
                FrameRequest frameFour  = _mockFramesFactory.GetInvalidFrameRequest();
                Karass       karass     = KarassFactory.Get(
                    new List <List <Action> >(),
                    new List <List <Action> >(),
                    new List <FrameRequest[]>
                {
                    new[]
                    {
                        frameOne,
                        frameTwo,
                        frameThree,
                        frameFour
                    }
                });
                KanKan kanKan = new KanKan(karass, new FrameFactoryDummy());

                Assert.True(kanKan.CurrentState.NextFrames.Contains(frameOne));
                Assert.False(kanKan.CurrentState.NextFrames.Contains(frameTwo));
                Assert.False(kanKan.CurrentState.NextFrames.Contains(frameThree));
                Assert.False(kanKan.CurrentState.NextFrames.Contains(frameFour));
            }
示例#4
0
            public void WhenAddedThenMethodsAreInInList_ExampleTwo()
            {
                Action setupOne  = () => { };
                Karass karassOne = KarassFactory.Get(
                    CreateActionListWith(setupOne),
                    new List <List <Action> >(),
                    new List <FrameRequest[]>());
                Action setupTwo  = () => { };
                Karass karassTwo = KarassFactory.Get(
                    CreateActionListWith(setupTwo),
                    new List <List <Action> >(),
                    new List <FrameRequest[]>());

                Action setupThree  = () => { };
                Karass karassThree = KarassFactory.Get(
                    CreateActionListWith(setupThree),
                    new List <List <Action> >(),
                    new List <FrameRequest[]>());

                Action setupFour  = () => { };
                Karass karassFour = KarassFactory.Get(
                    CreateActionListWith(setupFour),
                    new List <List <Action> >(),
                    new List <FrameRequest[]>());


                Karass combinedKarass = karassOne + karassTwo + karassThree + karassFour;

                Assert.True(combinedKarass.SetupActions.Count == 4);
                Assert.True(combinedKarass.SetupActions[0].Contains(setupOne));
                Assert.True(combinedKarass.SetupActions[1].Contains(setupTwo));
                Assert.True(combinedKarass.SetupActions[2].Contains(setupThree));
                Assert.True(combinedKarass.SetupActions[3].Contains(setupFour));
            }
示例#5
0
            public void WhenAddedThenFrameSetsContainArrays()
            {
                FrameRequest[] frameSetArrayOne = { };

                List <FrameRequest[]> frameSetOne = new List <FrameRequest[]>
                {
                    frameSetArrayOne
                };


                FrameRequest[] frameSetArrayTwo = { };

                List <FrameRequest[]> frameSetTwo = new List <FrameRequest[]>
                {
                    frameSetArrayTwo
                };

                Karass karassOne = KarassFactory.Get(
                    new List <List <Action> >(),
                    new List <List <Action> >(),
                    frameSetOne);

                Karass karassTwo = KarassFactory.Get(
                    new List <List <Action> >(),
                    new List <List <Action> >(),
                    frameSetTwo);

                Karass combinedKarass = karassOne + karassTwo;

                Assert.True(combinedKarass.FramesCollection.Count == 2);
                Assert.True(combinedKarass.FramesCollection.Contains(frameSetArrayOne));
                Assert.True(combinedKarass.FramesCollection.Contains(frameSetArrayTwo));
            }
        public void CurrentFramesReturnsNextFrames()
        {
            KarassFactory     karassFactory     = new KarassFactory();
            IDependencies     dependencies      = new KarassDependencies();
            FrameFactory      frameFactory      = new FrameFactory(dependencies);
            MockFramesFactory mockFramesFactory = new MockFramesFactory(frameFactory);

            IKarass karass = karassFactory.Get(new List <Action>(), new List <Action>(), new List <FrameRequest[]>()
            {
                new FrameRequest[]
                {
                    mockFramesFactory.GetValidFrameRequest((_) => true),
                    mockFramesFactory.GetValidFrameRequest((_) => true),
                    mockFramesFactory.GetValidFrameRequest((_) => true),
                    mockFramesFactory.GetValidFrameRequest((_) => true),
                    mockFramesFactory.GetValidFrameRequest((_) => true),
                    mockFramesFactory.GetValidFrameRequest((_) => true),
                    mockFramesFactory.GetValidFrameRequest((_) => true),
                    mockFramesFactory.GetValidFrameRequest((_) => true),
                    mockFramesFactory.GetValidFrameRequest((_) => true),
                    mockFramesFactory.GetValidFrameRequest((_) => true),
                }
            });

            Assert.True(karass.FramesCollection[0].Length == 10);

            KanKan kanKan = new KanKan(karass, frameFactory);

            for (int i = 0; i < 10; i++)
            {
                Assert.AreEqual(kanKan.Current, kanKan.CurrentState.NextFrames);
                kanKan.MoveNext();
            }
        }
        public void BothKarassSetupAndTeardownWillBeRun()
        {
            KarassFactory karassFactory = new KarassFactory();

            bool karassOneSetupRun = false;

            void KarassOneSetupSpy()
            {
                karassOneSetupRun = true;
            }

            bool karassTwoSetupRun = false;

            void KarassTwoSetupSpy()
            {
                karassTwoSetupRun = true;
            }

            bool karassOneTeardownRun = false;

            void KarassOneTeardownSpy()
            {
                karassOneTeardownRun = true;
            }

            bool karassTwoTeardownRun = false;

            void KarassTwoTeardownSpy()
            {
                karassTwoTeardownRun = true;
            }

            Karass karassOne = karassFactory.Get(KarassOneSetupSpy, KarassOneTeardownSpy,
                                                 new List <FrameRequest[]>());

            Karass karassTwo = karassFactory.Get(KarassTwoSetupSpy, KarassTwoTeardownSpy,
                                                 new List <FrameRequest[]>());

            KanKan kankan = new KanKan(new IKarass[] { karassOne, karassTwo }, new FrameFactory(new KarassDependencies()));

            kankan.MoveNext();

            Assert.True(karassOneSetupRun);
            Assert.True(karassTwoSetupRun);
            Assert.True(karassOneTeardownRun);
            Assert.True(karassTwoTeardownRun);
        }
示例#8
0
            public void SetupIsRunOnFirstMoveNextOnly()
            {
                int    setupCounter = 0;
                Action setup        = () => { setupCounter++; };
                Karass testKarass   = KarassFactory.Get(CreateActionListWith(setup), new List <List <Action> >(), Frames);

                KanKan kankan = new KanKan(testKarass, _frameFactory);

                kankan.MoveNext();
                Assert.True(setupCounter == 1);
                kankan.MoveNext();
                Assert.True(setupCounter == 1);
            }
示例#9
0
            public void WhenAddedThenFrameSetsContainFrames()
            {
                FrameRequest frameSetOneFrameOne = MockFramesFactory.GetInvalidFrameRequest();
                FrameRequest frameSetOneFrameTwo = MockFramesFactory.GetInvalidFrameRequest();

                FrameRequest[] frameSetArrayOne =
                {
                    frameSetOneFrameOne,
                    frameSetOneFrameTwo
                };

                List <FrameRequest[]> frameSetOne = new List <FrameRequest[]>
                {
                    frameSetArrayOne
                };

                FrameRequest frameSetTwoFrameOne = MockFramesFactory.GetInvalidFrameRequest();
                FrameRequest frameSetTwoFrameTwo = MockFramesFactory.GetInvalidFrameRequest();

                FrameRequest[] frameSetArrayTwo =
                {
                    frameSetTwoFrameOne,
                    frameSetTwoFrameTwo
                };

                List <FrameRequest[]> frameSetTwo = new List <FrameRequest[]>
                {
                    frameSetArrayTwo
                };

                Karass karassOne = KarassFactory.Get(
                    new List <List <Action> >(),
                    new List <List <Action> >(),
                    frameSetOne);

                Karass karassTwo = KarassFactory.Get(
                    new List <List <Action> >(),
                    new List <List <Action> >(),
                    frameSetTwo);

                Karass combinedKarass = karassOne + karassTwo;

                Assert.True(combinedKarass.FramesCollection.Count == 2);
                Assert.True(combinedKarass.FramesCollection.Contains(frameSetArrayOne));
                Assert.True(combinedKarass.FramesCollection.Contains(frameSetArrayTwo));

                Assert.True(combinedKarass.FramesCollection.Any(_ => _.Contains(frameSetOneFrameOne)));
                Assert.True(combinedKarass.FramesCollection.Any(_ => _.Contains(frameSetOneFrameTwo)));
                Assert.True(combinedKarass.FramesCollection.Any(_ => _.Contains(frameSetTwoFrameOne)));
                Assert.True(combinedKarass.FramesCollection.Any(_ => _.Contains(frameSetTwoFrameTwo)));
            }
示例#10
0
                public void SetupAndTeardownIsRun()
                {
                    int    setupCounter    = 0;
                    int    teardownCounter = 0;
                    Action setup           = () => { setupCounter++; };
                    Action teardown        = () => { teardownCounter++; };
                    Karass testKarass      = _karassFactory.Get(CreateActionListWith(setup), CreateActionListWith(teardown),
                                                                Frames);

                    KanKan kanKan = new KanKan(testKarass, _frameFactory);

                    kanKan.MoveNext();

                    Assert.True(setupCounter == 1);
                    Assert.True(teardownCounter == 1);
                    Assert.True(_frameRun);
                }
            public void ThenTheFrameIsInCurrentFrames()
            {
                FrameRequest frame = _mockFramesFactory.GetInvalidFrameRequest();

                Karass karass = KarassFactory.Get(
                    new List <List <Action> >(),
                    new List <List <Action> >(),
                    new List <FrameRequest[]>
                {
                    new[]
                    {
                        frame
                    }
                });
                KanKan kanKan = new KanKan(karass, new FrameFactoryDummy());

                Assert.True(kanKan.CurrentState.NextFrames.Contains(frame));
            }
            public void ThenMethodsArePutIntoCorrectArrays()
            {
                void SetupDummy()
                {
                }

                void TearDownDummy()
                {
                }

                KarassFactory karassFactory = new KarassFactory();
                Karass        karass        = karassFactory.Get(SetupDummy, TearDownDummy, Frames);

                Assert.NotNull(karass);
                Assert.True(karass.SetupActions[0].Contains(SetupDummy));
                Assert.True(karass.TeardownActions[0].Contains(TearDownDummy));
                Assert.AreEqual(karass.FramesCollection, Frames);
            }
示例#13
0
            public void WhenAddedThenMethodsAreInInList_ExampleOne()
            {
                Action teardownOne = () => { };
                Karass karassOne   = KarassFactory.Get(
                    new List <List <Action> >(),
                    CreateActionListWith(teardownOne),
                    new List <FrameRequest[]>());
                Action teardownTwo = () => { };
                Karass karassTwo   = KarassFactory.Get(
                    new List <List <Action> >(),
                    CreateActionListWith(teardownTwo),
                    new List <FrameRequest[]>());

                Karass combinedKarass = karassOne + karassTwo;

                Assert.True(combinedKarass.TeardownActions.Count == 2);
                Assert.True(combinedKarass.TeardownActions[0].Contains(teardownOne));
                Assert.True(combinedKarass.TeardownActions[1].Contains(teardownTwo));
            }
示例#14
0
            public void ThenMethodsArePutIntoCorrectArrays()
            {
                void SetupDummyOne()
                {
                }

                void SetupDummyTwo()
                {
                }

                void TearDownDummyOne()
                {
                }

                void TearDownDummyTwo()
                {
                }

                List <Action> setup = new List <Action>
                {
                    SetupDummyOne,
                    SetupDummyTwo
                };

                List <Action> teardown = new List <Action>
                {
                    TearDownDummyOne,
                    TearDownDummyTwo
                };

                DependenciesDummy dependencies  = new DependenciesDummy();
                FrameFactoryDummy frameFactory  = new FrameFactoryDummy();
                KarassFactory     karassFactory = new KarassFactory();
                Karass            karass        = karassFactory.Get(setup, teardown, Frames);

                Assert.NotNull(karass);

                Assert.AreEqual(karass.SetupActions[0], setup);
                Assert.AreEqual(karass.TeardownActions[0], teardown);
                Assert.AreEqual(karass.FramesCollection[0], Frames);
            }
示例#15
0
            public void ThenOnlyTheFirstFramesAreInCurrentFrames()
            {
                FrameRequest setOneFrameOne   = _mockFramesFactory.GetInvalidFrameRequest();
                FrameRequest setOneFrameTwo   = _mockFramesFactory.GetInvalidFrameRequest();
                FrameRequest setOneFrameThree = _mockFramesFactory.GetInvalidFrameRequest();


                FrameRequest setTwoFrameOne   = _mockFramesFactory.GetInvalidFrameRequest();
                FrameRequest setTwoFrameTwo   = _mockFramesFactory.GetInvalidFrameRequest();
                FrameRequest setTwoFrameThree = _mockFramesFactory.GetInvalidFrameRequest();
                Karass       karass           = KarassFactory.Get(
                    new List <List <Action> >(),
                    new List <List <Action> >(),
                    new List <FrameRequest[]>
                {
                    new[]
                    {
                        setOneFrameOne,
                        setOneFrameTwo,
                        setOneFrameThree
                    },
                    new[]
                    {
                        setTwoFrameOne,
                        setTwoFrameTwo,
                        setTwoFrameThree
                    }
                });
                KanKan kanKan = new KanKan(karass, new FrameFactoryDummy());

                Assert.True(kanKan.CurrentState.NextFrames.Contains(setOneFrameOne));
                Assert.True(kanKan.CurrentState.NextFrames.Contains(setTwoFrameOne));

                Assert.False(kanKan.CurrentState.NextFrames.Contains(setOneFrameTwo));
                Assert.False(kanKan.CurrentState.NextFrames.Contains(setTwoFrameTwo));

                Assert.False(kanKan.CurrentState.NextFrames.Contains(setOneFrameTwo));
                Assert.False(kanKan.CurrentState.NextFrames.Contains(setTwoFrameTwo));
            }
示例#16
0
            public void ThenBothFramesAreInCurrentFrames()
            {
                FrameRequest setOneFrame = _mockFramesFactory.GetInvalidFrameRequest();
                FrameRequest setTwoFrame = _mockFramesFactory.GetInvalidFrameRequest();

                Karass karass = KarassFactory.Get(
                    new List <List <Action> >(),
                    new List <List <Action> >(),
                    new List <FrameRequest[]>
                {
                    new[]
                    {
                        setOneFrame
                    },
                    new[]
                    {
                        setTwoFrame
                    }
                });
                KanKan kanKan = new KanKan(karass, new FrameFactory(new KarassDependencies()));

                Assert.True(kanKan.CurrentState.NextFrames.Contains(setOneFrame));
                Assert.True(kanKan.CurrentState.NextFrames.Contains(setTwoFrame));
            }
        public void ThenKarassWillRunCorrectly()
        {
            bool karassOneSetupRun = false;

            void KarassOneSetupSpy()
            {
                karassOneSetupRun = true;
            }

            bool karassOneTeardownRun = false;

            void KarassOneTeardownSpy()
            {
                karassOneTeardownRun = true;
            }

            bool karassOneFrameOneRun = false;

            bool KarassOneFrameOneSpy(string message)
            {
                karassOneFrameOneRun = true;
                return(true);
            }

            FrameRequest karassOneFrameOneSpyRequest =
                _mockFramesFactory.GetValidFrameRequest(KarassOneFrameOneSpy);

            Karass karassOne = _karassFactory.Get(KarassOneSetupSpy, KarassOneTeardownSpy,
                                                  new List <FrameRequest[]>
            {
                new[]
                {
                    karassOneFrameOneSpyRequest
                }
            });


            bool karassTwoSetupRun = false;

            void KarassTwoSetupSpy()
            {
                karassTwoSetupRun = true;
            }

            bool karassTwoTeardownRun = false;

            void KarassTwoTeardownSpy()
            {
                karassTwoTeardownRun = true;
            }

            bool karassTwoFrameOneRun   = false;
            bool karassTwoFrameTwoRun   = false;
            bool karassTwoFrameThreeRun = false;

            bool KarassTwoFrameOneSpy(string message)
            {
                karassTwoFrameOneRun = true;
                return(true);
            }

            bool KarassTwoFrameTwoSpy(string message)
            {
                karassTwoFrameTwoRun = true;
                return(true);
            }

            bool KarassTwoFrameThreeSpy(string message)
            {
                karassTwoFrameThreeRun = true;
                return(true);
            }

            FrameRequest karassTwoFrameOneSpyRequest =
                _mockFramesFactory.GetValidFrameRequest(KarassTwoFrameOneSpy);


            FrameRequest karassTwoFrameTwoSpyRequest =
                _mockFramesFactory.GetValidFrameRequest(KarassTwoFrameTwoSpy);


            FrameRequest karassTwoFrameThreeSpyRequest =
                _mockFramesFactory.GetValidFrameRequest(KarassTwoFrameThreeSpy);


            Karass karassTwo = _karassFactory.Get(KarassTwoSetupSpy, KarassTwoTeardownSpy,
                                                  new List <FrameRequest[]>
            {
                new[]
                {
                    karassTwoFrameOneSpyRequest,
                    karassTwoFrameTwoSpyRequest,
                    karassTwoFrameThreeSpyRequest,
                }
            });


            bool karassThreeSetupRun = false;

            void KarassThreeSetupSpy()
            {
                karassThreeSetupRun = true;
            }

            bool karassThreeTeardownRun = false;

            void KarassThreeTeardownSpy()
            {
                karassThreeTeardownRun = true;
            }

            bool karassThreeFrameOneRun = false;


            bool KarassThreeFrameOneSpy(string message)
            {
                karassThreeFrameOneRun = true;
                return(true);
            }

            FrameRequest karassThreeFrameOneSpyRequest =
                _mockFramesFactory.GetValidFrameRequest(KarassThreeFrameOneSpy);

            Karass karassThree = _karassFactory.Get(KarassThreeSetupSpy, KarassThreeTeardownSpy,
                                                    new List <FrameRequest[]>
            {
                new[]
                {
                    karassThreeFrameOneSpyRequest
                }
            });


            bool karassFourSetupRun = false;

            void KarassFourSetupSpy()
            {
                karassFourSetupRun = true;
            }

            bool karassFourTeardownRun = false;

            void KarassFourTeardownSpy()
            {
                karassFourTeardownRun = true;
            }

            bool karassFourFrameOneRun = false;
            bool karassFourFrameTwoRun = false;

            bool KarassFourFrameOneSpy(string message)
            {
                karassFourFrameOneRun = true;
                return(true);
            }

            bool KarassFourFrameTwoSpy(string message)
            {
                karassFourFrameTwoRun = true;
                return(true);
            }

            FrameRequest karassFourFrameOneSpyRequest =
                _mockFramesFactory.GetValidFrameRequest(KarassFourFrameOneSpy);


            FrameRequest karassFourFrameTwoSpyRequest =
                _mockFramesFactory.GetValidFrameRequest(KarassFourFrameTwoSpy);


            Karass karassFour = _karassFactory.Get(KarassFourSetupSpy, KarassFourTeardownSpy,
                                                   new List <FrameRequest[]>
            {
                new[]
                {
                    karassFourFrameOneSpyRequest,
                    karassFourFrameTwoSpyRequest
                }
            });

            KanKan kankan = new KanKan(
                new IKarass[] { karassOne, karassTwo, karassThree, karassFour },
                _frameFactory);
            bool moveNext = kankan.MoveNext();

            CheckFirstFrame(karassOneSetupRun, karassOneTeardownRun, karassOneFrameOneRun, karassTwoSetupRun,
                            karassTwoTeardownRun, karassTwoFrameOneRun, karassTwoFrameTwoRun, karassTwoFrameThreeRun, moveNext,
                            karassThreeSetupRun, karassThreeTeardownRun, karassThreeFrameOneRun, karassFourSetupRun,
                            karassFourTeardownRun, karassFourFrameOneRun, karassFourFrameTwoRun);

            moveNext = kankan.MoveNext();


            CheckSecondFrame(karassOneSetupRun, karassOneTeardownRun, karassOneFrameOneRun, karassTwoSetupRun,
                             karassTwoTeardownRun, karassTwoFrameOneRun, karassTwoFrameTwoRun, karassTwoFrameThreeRun,
                             karassThreeSetupRun, karassThreeTeardownRun, karassThreeFrameOneRun, karassFourSetupRun,
                             karassFourTeardownRun, karassFourFrameOneRun, karassFourFrameTwoRun, moveNext);


            moveNext = kankan.MoveNext();

            CheckThirdFrame(karassOneSetupRun, karassOneTeardownRun, karassOneFrameOneRun, karassTwoSetupRun,
                            karassTwoTeardownRun, karassTwoFrameOneRun, karassTwoFrameTwoRun, karassTwoFrameThreeRun,
                            karassThreeSetupRun, karassThreeTeardownRun, karassThreeFrameOneRun, karassFourSetupRun,
                            karassFourTeardownRun, karassFourFrameOneRun, karassFourFrameTwoRun, moveNext);
            moveNext = kankan.MoveNext();

            CheckFourthFrame(karassOneSetupRun, karassOneTeardownRun, karassOneFrameOneRun, karassTwoSetupRun,
                             karassTwoTeardownRun, karassTwoFrameOneRun, karassTwoFrameTwoRun, karassTwoFrameThreeRun,
                             karassThreeSetupRun, karassThreeTeardownRun, karassThreeFrameOneRun, karassFourSetupRun,
                             karassFourTeardownRun, karassFourFrameOneRun, karassFourFrameTwoRun, moveNext);

            moveNext = kankan.MoveNext();

            CheckFifthFrame(karassOneSetupRun, karassOneTeardownRun, karassOneFrameOneRun, karassTwoSetupRun,
                            karassTwoTeardownRun, karassTwoFrameOneRun, karassTwoFrameTwoRun, karassTwoFrameThreeRun,
                            karassThreeSetupRun, karassThreeTeardownRun, karassThreeFrameOneRun, karassFourSetupRun,
                            karassFourTeardownRun, karassFourFrameOneRun, karassFourFrameTwoRun, moveNext);

            moveNext = kankan.MoveNext();

            CheckSixthFrame(karassOneSetupRun, karassOneTeardownRun, karassOneFrameOneRun, karassTwoSetupRun,
                            karassTwoTeardownRun, karassTwoFrameOneRun, karassTwoFrameTwoRun, karassTwoFrameThreeRun,
                            karassThreeSetupRun, karassThreeTeardownRun, karassThreeFrameOneRun, karassFourSetupRun,
                            karassFourTeardownRun, karassFourFrameOneRun, karassFourFrameTwoRun, moveNext);

            moveNext = kankan.MoveNext();

            CheckSeventhFrame(karassOneSetupRun, karassOneTeardownRun, karassOneFrameOneRun, karassTwoSetupRun,
                              karassTwoTeardownRun, karassTwoFrameOneRun, karassTwoFrameTwoRun, karassTwoFrameThreeRun,
                              karassThreeSetupRun, karassThreeTeardownRun, karassThreeFrameOneRun, karassFourSetupRun,
                              karassFourTeardownRun, karassFourFrameOneRun, karassFourFrameTwoRun, moveNext);
        }
                public void ThenMethodsArePutIntoCorrectArrays()
                {
                    void SetupOneDummyOne()
                    {
                    }

                    void SetupOneDummyTwo()
                    {
                    }

                    void SetupTwoDummyOne()
                    {
                    }

                    void SetupTwoDummyTwo()
                    {
                    }

                    void TearOneDownDummyOne()
                    {
                    }

                    void TearOneDownDummyTwo()
                    {
                    }

                    void TearTwoDownDummyOne()
                    {
                    }

                    void TearTwoDownDummyTwo()
                    {
                    }

                    var setupOne = new List <Action>
                    {
                        SetupOneDummyOne,
                        SetupOneDummyTwo
                    };
                    var setupTwo = new List <Action>
                    {
                        SetupTwoDummyOne,
                        SetupTwoDummyTwo
                    };

                    var teardownOne = new List <Action>
                    {
                        TearOneDownDummyOne,
                        TearOneDownDummyTwo
                    };
                    var teardownTwo = new List <Action>
                    {
                        TearTwoDownDummyOne,
                        TearTwoDownDummyTwo
                    };
                    List <List <Action> > setup = new List <List <Action> >
                    {
                        setupOne,
                        setupTwo
                    };

                    List <List <Action> > teardown = new List <List <Action> >
                    {
                        teardownOne,
                        teardownTwo
                    };

                    KarassFactory karassFactory = new KarassFactory();
                    Karass        karass        = karassFactory.Get(setup, teardown, Frames);

                    Assert.NotNull(karass);

                    Assert.AreEqual(karass.SetupActions[0], setupOne);
                    Assert.AreEqual(karass.SetupActions[1], setupTwo);

                    Assert.AreEqual(karass.SetupActions, setup);

                    Assert.AreEqual(karass.TeardownActions[0], teardownOne);
                    Assert.AreEqual(karass.TeardownActions[1], teardownTwo);

                    Assert.AreEqual(karass.TeardownActions, teardown);
                    Assert.AreEqual(karass.FramesCollection, Frames);
                }
示例#19
0
            public void ThenNextFramesIsCorrectlyUpdated()
            {
                FrameRequest setOneFrameOneSpyRequest = _mockFramesFactory.GetValidFrameRequest(SetOneFrameOneSpy);
                FrameRequest setOneFrameTwoSpyRequest = _mockFramesFactory.GetValidFrameRequest(SetOneFrameTwoSpy);
                FrameRequest setTwoFrameOneSpyRequest = _mockFramesFactory.GetValidFrameRequest(SetTwoFrameOneSpy);
                FrameRequest setTwoFrameTwoSpyRequest = _mockFramesFactory.GetValidFrameRequest(SetTwoFrameTwoSpy);


                bool setOneFrameOneRun = false;

                bool SetOneFrameOneSpy(string s)
                {
                    setOneFrameOneRun = true;
                    return(true);
                }

                bool setOneFrameTwoRun = false;

                bool SetOneFrameTwoSpy(string s)
                {
                    setOneFrameTwoRun = true;
                    return(true);
                }

                bool setTwoFrameOneRun = false;

                bool SetTwoFrameOneSpy(string s)
                {
                    setTwoFrameOneRun = true;
                    return(true);
                }

                bool setTwoFrameTwoRun = false;

                bool SetTwoFrameTwoSpy(string s)
                {
                    setTwoFrameTwoRun = true;
                    return(true);
                }

                Karass karass = _karassFactory.Get(new List <List <Action> >(), new List <List <Action> >(),
                                                   new List <FrameRequest[]>
                {
                    new[]
                    {
                        setOneFrameOneSpyRequest,
                        setOneFrameTwoSpyRequest
                    },
                    new[]
                    {
                        setTwoFrameOneSpyRequest,
                        setTwoFrameTwoSpyRequest
                    }
                });

                KanKan kankan = new KanKan(karass, _frameFactory);

                Assert.True(kankan.CurrentState.NextFrames.Count == 2);
                Assert.True(kankan.CurrentState.NextFrames.Contains(setOneFrameOneSpyRequest));
                Assert.True(kankan.CurrentState.NextFrames.Contains(setTwoFrameOneSpyRequest));

                kankan.MoveNext();
                Assert.True(kankan.CurrentState.NextFrames.Count == 2);
                Assert.True(kankan.CurrentState.NextFrames.Contains(setOneFrameTwoSpyRequest));
                Assert.True(kankan.CurrentState.NextFrames.Contains(setTwoFrameTwoSpyRequest));

                Assert.True(setOneFrameOneRun);
                Assert.False(setOneFrameTwoRun);
                Assert.True(setTwoFrameOneRun);
                Assert.False(setTwoFrameTwoRun);

                kankan.MoveNext();

                Assert.False(kankan.CurrentState.NextFrames.Any());

                Assert.True(setOneFrameOneRun);
                Assert.True(setOneFrameTwoRun);
                Assert.True(setTwoFrameOneRun);
                Assert.True(setTwoFrameTwoRun);
            }