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"); }
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"); }