Exemplo n.º 1
0
        public void ExecuteMethodCorrectlyExecutesFrameRequest(string testMessage, string testActionDataPayload)
        {
            //Arrange
            KarassDependenciesSpy dependenciesSpy = new KarassDependenciesSpy();
            FrameStructDummy      frameActionData = new FrameStructDummy
            {
                Test = testActionDataPayload
            };

            FrameRequest frameRequest = new FrameRequest(frameActionData);
            KarassFrameSpy <FrameStructDummy> frameAction = new KarassFrameSpy <FrameStructDummy>(dependenciesSpy);

            dependenciesSpy.Register <IKarassFrame <FrameStructDummy> >(() => frameAction);
            FrameFactory frameFactory = new FrameFactory(dependenciesSpy);

            frameFactory.RegisterRoute <FrameStructDummy, IKarassFrame <FrameStructDummy> >();

            //Act
            frameFactory.Execute(frameRequest, testMessage);

            //Assert
            Assert.True(dependenciesSpy.RegisterCallCount == 1);
            Assert.True(dependenciesSpy.GetCallCount == 1);
            Assert.True(frameAction.ExecuteCallCount == 1);
            Assert.True(frameAction.RequestData.Test == testActionDataPayload);
            Assert.True(frameAction.Message == testMessage);
            Assert.True(frameAction.Dependencies == dependenciesSpy);
        }
Exemplo n.º 2
0
        public void GetMethodReturnsCorrectData(string testString, string message)
        {
            // Arrange
            KarassDependenciesSpy dependenciesSpy = new KarassDependenciesSpy();
            FrameStructDummy      frameActionData = new FrameStructDummy
            {
                Test = testString
            };
            KarassFrameSpy <FrameStructDummy> frameAction = new KarassFrameSpy <FrameStructDummy>(dependenciesSpy);

            dependenciesSpy.Register <IKarassFrame <FrameStructDummy> >(() => frameAction);
            FrameFactory frameFactory = new FrameFactory(dependenciesSpy);

            frameFactory.RegisterRoute <FrameStructDummy, IKarassFrame <FrameStructDummy> >();

            //Act
            IKarassFrame <FrameStructDummy> frame = frameFactory.Get <FrameStructDummy>();

            frame.Execute(message, frameActionData);


            //Assert
            Assert.True(dependenciesSpy.GetCallCount == 1);
            Assert.True(dependenciesSpy.RegisterCallCount == 1);
            Assert.True(frameAction.ExecuteCallCount == 1);
            Assert.True(frame.Message == message);
            Assert.True(frame.RequestData.Test == testString);
            Assert.AreEqual(frameAction.Dependencies, dependenciesSpy);
        }