Пример #1
0
        public TestEngineFactory WithBotSupport(IKnowWhatBotsDo ikwbd = null, IProvideBotInteractivity ipba = null)
        {
            injectBotSupport = true;
            if (ikwbd == null)
            {
                if (ipba != null)
                {
                    throw new InvalidOperationException("Need both null");
                }
                bd2MessageBasedBotSupport mbSupport = new bd2MessageBasedBotSupport();
                inj_ikwbd = mbSupport;
                inj_ipba  = mbSupport;
            }
            else
            {
                inj_ikwbd = ikwbd;
                inj_ipba  = ipba;
            }

            return(this);
        }
Пример #2
0
        public void MockBot_AccellerateCallsReadSpeedMessage()
        {
            Hub testHub        = new Hub(true);
            var actionProvider = new bd2MessageBasedBotSupport();

            actionProvider.InjectHub(testHub);
            bool messageRecieved = false;

            testHub.LookFor <Message_Query>(ab => {
                if (ab.SubKind == KnownSubkinds.ReadSpeed)
                {
                    messageRecieved           = true;
                    NavigationInfoContext nic = new NavigationInfoContext();
                    nic.SpeedDelta            = 1;
                    ab.ResponseContext        = nic;
                }
            });
            var sut = new MockBotFactory().CreateBasicMockBot().WithThisActionProvider(actionProvider, actionProvider).ToBot();

            sut.Accelerate();
            Assert.True(messageRecieved, "The query speed message was not requested by the accelerate function");
        }
Пример #3
0
        public void MockBot_AccellerateCallsAccellerateMessage()
        {
            var testHub = new Hub(true);

            testHub.UseStrongReferences = true;
            var engineHub = new bd2MessageBasedBotSupport();

            engineHub.InjectHub(testHub);
            bool messageRecieved = false;
            int  valueChange     = 0;

            testHub.LookFor <Message_Query>(ab => {
                if (ab.SubKind == KnownSubkinds.ReadSpeed)
                {
                    NavigationInfoContext nic = new NavigationInfoContext();
                    nic.SpeedDelta            = 1;
                    ab.ResponseContext        = nic;
                }
            });

            testHub.LookFor <Message_BotPerformAction>(ab => {
                if (ab.SubKind == KnownSubkinds.ChangeSpeed)
                {
                    messageRecieved           = true;
                    NavigationInfoContext nic = (NavigationInfoContext)ab.RequestContext;
                    Assert.NotNull(nic);
                    valueChange = nic.SpeedDelta;
                }
            });

            var sut = new MockBotFactory().CreateBasicMockBot().WithThisActionProvider(engineHub, engineHub).ToBot();

            sut.Accelerate();
            Assert.True(messageRecieved, "The accellerate call did not send the change speed request message");
            Assert.True(valueChange == 1, "The accelerate value should be 1");
        }