public GivenATestDiscoveryStartMessageHandler() { _dotnetTestMock = new Mock <IDotnetTest>(); _dotnetTestMock.Setup(d => d.State).Returns(DotnetTestState.VersionCheckCompleted); _dotnetTestMock.Setup(d => d.PathToAssemblyUnderTest).Returns(AssemblyUnderTest); _dotnetTestAtVersionCheckCompletedState = _dotnetTestMock.Object; _testRunnerMock = new Mock <ITestRunner>(); _testRunnerFactoryMock = new Mock <ITestRunnerFactory>(); _testRunnerFactoryMock .Setup(c => c.CreateTestRunner(It.IsAny <DiscoverTestsArgumentsBuilder>())) .Callback <ITestRunnerArgumentsBuilder>(r => _argumentsBuilder = r as DiscoverTestsArgumentsBuilder) .Returns(_testRunnerMock.Object); _adapterChannelMock = new Mock <IReportingChannel>(); _testRunnerChannelMock = new Mock <IReportingChannel>(); _testRunnerChannelMock.Setup(t => t.Port).Returns(TestRunnerPort); _reportingChannelFactoryMock = new Mock <IReportingChannelFactory>(); _reportingChannelFactoryMock.Setup(r => r.CreateTestRunnerChannel()).Returns(_testRunnerChannelMock.Object); _testDiscoveryStartMessageHandler = new TestDiscoveryStartMessageHandler( _testRunnerFactoryMock.Object, _adapterChannelMock.Object, _reportingChannelFactoryMock.Object); _validMessage = new Message { MessageType = TestMessageTypes.TestDiscoveryStart }; }
private void DoHandleMessage(IDotnetTest dotnetTest, Message message) { _adapterChannel.Send(new Message { MessageType = MessageType(dotnetTest) }); }
public GivenATestDiscoveryStartMessageHandler() { _dotnetTestMock = new Mock<IDotnetTest>(); _dotnetTestMock.Setup(d => d.State).Returns(DotnetTestState.VersionCheckCompleted); _dotnetTestMock.Setup(d => d.PathToAssemblyUnderTest).Returns(AssemblyUnderTest); _dotnetTestAtVersionCheckCompletedState = _dotnetTestMock.Object; _testRunnerMock = new Mock<ITestRunner>(); _testRunnerFactoryMock = new Mock<ITestRunnerFactory>(); _testRunnerFactoryMock .Setup(c => c.CreateTestRunner(It.IsAny<DiscoverTestsArgumentsBuilder>())) .Callback<ITestRunnerArgumentsBuilder>(r => _argumentsBuilder = r as DiscoverTestsArgumentsBuilder) .Returns(_testRunnerMock.Object); _adapterChannelMock = new Mock<IReportingChannel>(); _testRunnerChannelMock = new Mock<IReportingChannel>(); _testRunnerChannelMock.Setup(t => t.Port).Returns(TestRunnerPort); _reportingChannelFactoryMock = new Mock<IReportingChannelFactory>(); _reportingChannelFactoryMock.Setup(r => r.CreateTestRunnerChannel()).Returns(_testRunnerChannelMock.Object); _testDiscoveryStartMessageHandler = new TestDiscoveryStartMessageHandler( _testRunnerFactoryMock.Object, _adapterChannelMock.Object, _reportingChannelFactoryMock.Object); _validMessage = new Message { MessageType = TestMessageTypes.TestDiscoveryStart }; }
public DotnetTestState HandleMessage(IDotnetTest dotnetTest, Message message) { var error = $"No handler for message '{message.MessageType}' when at state '{dotnetTest.State}'"; TestHostTracing.Source.TraceEvent(TraceEventType.Error, 0, error); _adapterChannel.SendError(error); throw new InvalidOperationException(error); }
public DotnetTestState HandleMessage(IDotnetTest dotnetTest, Message message) { var nextState = DotnetTestState.NoOp; if (CanHandleMessage(dotnetTest, message)) { HandleMessage(message); nextState = _nextStateIfHandled; } return nextState; }
public DotnetTestState HandleMessage(IDotnetTest dotnetTest, Message message) { var nextState = DotnetTestState.NoOp; if (CanHandleMessage(dotnetTest, message)) { HandleMessage(dotnetTest); nextState = DotnetTestState.TestDiscoveryStarted; } return nextState; }
public DotnetTestState HandleMessage(IDotnetTest dotnetTest, Message message) { var nextState = DotnetTestState.NoOp; if (CanHandleMessage(dotnetTest, message)) { DoHandleMessage(dotnetTest, message); nextState = NextState(dotnetTest); } return nextState; }
public static IDotnetTest AddTestDiscoveryMessageHandlers( this IDotnetTest dotnetTest, IReportingChannel adapterChannel, IReportingChannelFactory reportingChannelFactory, ITestRunnerFactory testRunnerFactory) { dotnetTest.AddMessageHandler( new TestDiscoveryStartMessageHandler(testRunnerFactory, adapterChannel, reportingChannelFactory)); return(dotnetTest); }
public DotnetTestState HandleMessage(IDotnetTest dotnetTest, Message message) { var nextState = DotnetTestState.NoOp; if (CanHandleMessage(dotnetTest, message)) { HandleMessage(message); nextState = DotnetTestState.VersionCheckCompleted; } return nextState; }
public DotnetTestState HandleMessage(IDotnetTest dotnetTest, Message message) { var nextState = DotnetTestState.NoOp; if (CanHandleMessage(dotnetTest, message)) { HandleMessage(message); nextState = DotnetTestState.VersionCheckCompleted; } return(nextState); }
public DotnetTestState HandleMessage(IDotnetTest dotnetTest, Message message) { var nextState = DotnetTestState.NoOp; if (TestMessageTypes.TestSessionTerminate.Equals(message.MessageType)) { nextState = DotnetTestState.Terminated; _messages.Drain(); } return(nextState); }
public DotnetTestState HandleMessage(IDotnetTest dotnetTest, Message message) { var nextState = DotnetTestState.NoOp; if (CanHandleMessage(dotnetTest, message)) { DoHandleMessage(dotnetTest, message); nextState = DotnetTestState.TestExecutionSentTestRunnerProcessStartInfo; } return(nextState); }
public DotnetTestState HandleMessage(IDotnetTest dotnetTest, Message message) { var nextState = DotnetTestState.NoOp; if (CanHandleMessage(dotnetTest, message)) { HandleMessage(message); nextState = _nextStateIfHandled; } return(nextState); }
public DotnetTestState HandleMessage(IDotnetTest dotnetTest, Message message) { var nextState = DotnetTestState.NoOp; if (CanHandleMessage(dotnetTest, message)) { DoHandleMessage(dotnetTest, message); nextState = DotnetTestState.TestExecutionSentTestRunnerProcessStartInfo; } return nextState; }
public DotnetTestState HandleMessage(IDotnetTest dotnetTest, Message message) { var nextState = DotnetTestState.NoOp; if (CanHandleMessage(dotnetTest, message)) { HandleMessage(dotnetTest); nextState = DotnetTestState.TestDiscoveryStarted; } return(nextState); }
public DotnetTestState HandleMessage(IDotnetTest dotnetTest, Message message) { var nextState = DotnetTestState.NoOp; if (CanHandleMessage(dotnetTest, message)) { DoHandleMessage(dotnetTest, message); nextState = NextState(dotnetTest); } return(nextState); }
public DotnetTestState HandleMessage(IDotnetTest dotnetTest, Message message) { var nextState = DotnetTestState.NoOp; if (TestMessageTypes.TestSessionTerminate.Equals(message.MessageType)) { nextState = DotnetTestState.Terminated; _messages.Drain(); } return nextState; }
public static IDotnetTest AddNonSpecificMessageHandlers( this IDotnetTest dotnetTest, ITestMessagesCollection messages, IReportingChannel adapterChannel) { dotnetTest.TestSessionTerminateMessageHandler = new TestSessionTerminateMessageHandler(messages); dotnetTest.UnknownMessageHandler = new UnknownMessageHandler(adapterChannel); dotnetTest.AddMessageHandler(new VersionCheckMessageHandler(adapterChannel)); return(dotnetTest); }
public static IDotnetTest AddTestRunnnersMessageHandlers( this IDotnetTest dotnetTest, IReportingChannel adapterChannel, IReportingChannelFactory reportingChannelFactory) { dotnetTest.AddMessageHandler(new TestRunnerTestStartedMessageHandler(adapterChannel)); dotnetTest.AddMessageHandler(new TestRunnerTestResultMessageHandler(adapterChannel)); dotnetTest.AddMessageHandler(new TestRunnerTestFoundMessageHandler(adapterChannel)); dotnetTest.AddMessageHandler(new TestRunnerTestCompletedMessageHandler(adapterChannel)); dotnetTest.AddMessageHandler(new TestRunnerWaitingCommandMessageHandler(reportingChannelFactory)); return(dotnetTest); }
public static IDotnetTest AddTestRunMessageHandlers( this IDotnetTest dotnetTest, IReportingChannel adapterChannel, IReportingChannelFactory reportingChannelFactory, ITestRunnerFactory testRunnerFactory) { dotnetTest.AddMessageHandler(new GetTestRunnerProcessStartInfoMessageHandler( testRunnerFactory, adapterChannel, reportingChannelFactory)); return(dotnetTest); }
private void HandleMessage(IDotnetTest dotnetTest) { if (_testRunnerChannel == null) { const string errorMessage = "A test runner channel hasn't been created for TestRunnerWaitingCommandMessageHandler"; throw new InvalidOperationException(errorMessage); } _testRunnerChannel.Send(new Message { MessageType = TestMessageTypes.TestRunnerExecute, Payload = JToken.FromObject(new RunTestsMessage { Tests = new List<string>(dotnetTest.TestsToRun.OrEmptyIfNull()) }) }); }
private void HandleMessage(IDotnetTest dotnetTest) { if (_testRunnerChannel == null) { const string errorMessage = "A test runner channel hasn't been created for TestRunnerWaitingCommandMessageHandler"; throw new InvalidOperationException(errorMessage); } _testRunnerChannel.Send(new Message { MessageType = TestMessageTypes.TestRunnerExecute, Payload = JToken.FromObject(new RunTestsMessage { Tests = new List <string>(dotnetTest.TestsToRun.OrEmptyIfNull()) }) }); }
public GivenAVersionCheckMessageHandler() { _reportingChannelMock = new Mock <IReportingChannel>(); _versionCheckMessageHandler = new VersionCheckMessageHandler(_reportingChannelMock.Object); _validMessage = new Message { MessageType = TestMessageTypes.VersionCheck, Payload = JToken.FromObject(new ProtocolVersionMessage { Version = 99 }) }; var dotnetTestAtInitialStateMock = new Mock <IDotnetTest>(); dotnetTestAtInitialStateMock.Setup(d => d.State).Returns(DotnetTestState.InitialState); _dotnetTestAtInitialState = dotnetTestAtInitialStateMock.Object; }
private void DoHandleMessage(IDotnetTest dotnetTest, Message message) { var testRunnerChannel = _reportingChannelFactory.CreateChannelWithAnyAvailablePort(); dotnetTest.StartListeningTo(testRunnerChannel); testRunnerChannel.Accept(); var testRunner = _testRunnerFactory.CreateTestRunner( new RunTestsArgumentsBuilder(dotnetTest.PathToAssemblyUnderTest, testRunnerChannel.Port, message)); var processStartInfo = testRunner.GetProcessStartInfo(); _adapterChannel.Send(new Message { MessageType = TestMessageTypes.TestExecutionTestRunnerProcessStartInfo, Payload = JToken.FromObject(processStartInfo) }); }
private void DoHandleMessage(IDotnetTest dotnetTest, Message message) { var testRunnerChannel = _reportingChannelFactory.CreateTestRunnerChannel(); dotnetTest.StartListeningTo(testRunnerChannel); testRunnerChannel.Connect(); var testRunner = _testRunnerFactory.CreateTestRunner( new RunTestsArgumentsBuilder(dotnetTest.PathToAssemblyUnderTest, testRunnerChannel.Port, message)); dotnetTest.TestsToRun = message.Payload?.ToObject <RunTestsMessage>().Tests; var processStartInfo = testRunner.GetProcessStartInfo(); _adapterChannel.Send(new Message { MessageType = TestMessageTypes.TestExecutionTestRunnerProcessStartInfo, Payload = JToken.FromObject(processStartInfo) }); }
private void DiscoverTests(IDotnetTest dotnetTest) { var testRunnerResults = Enumerable.Empty <Message>(); try { var testRunnerChannel = _reportingChannelFactory.CreateTestRunnerChannel(); dotnetTest.StartListeningTo(testRunnerChannel); testRunnerChannel.Connect(); var testRunner = _testRunnerFactory.CreateTestRunner( new DiscoverTestsArgumentsBuilder(dotnetTest.PathToAssemblyUnderTest, testRunnerChannel.Port)); testRunner.RunTestCommand(); } catch (TestRunnerOperationFailedException e) { _adapterChannel.SendError(e.Message); } }
private void DiscoverTests(IDotnetTest dotnetTest) { var testRunnerResults = Enumerable.Empty<Message>(); try { var testRunnerChannel = _reportingChannelFactory.CreateTestRunnerChannel(); dotnetTest.StartListeningTo(testRunnerChannel); testRunnerChannel.Accept(); var testRunner = _testRunnerFactory.CreateTestRunner( new DiscoverTestsArgumentsBuilder(dotnetTest.PathToAssemblyUnderTest, testRunnerChannel.Port)); testRunner.RunTestCommand(); } catch (TestRunnerOperationFailedException e) { _adapterChannel.SendError(e.Message); } }
private static bool CanHandleMessage(IDotnetTest dotnetTest, Message message) { return dotnetTest.State == DotnetTestState.TestExecutionSentTestRunnerProcessStartInfo && message.MessageType == TestMessageTypes.TestRunnerWaitingCommand; }
private static bool CanHandleMessage(IDotnetTest dotnetTest, Message message) { return IsAtAnAcceptableState(dotnetTest) && message.MessageType == TestMessageTypes.TestExecutionGetTestRunnerProcessStartInfo; }
private static bool IsAtAnAcceptableState(IDotnetTest dotnetTest) { return(dotnetTest.State == DotnetTestState.TestDiscoveryStarted || dotnetTest.State == DotnetTestState.TestExecutionStarted); }
private static bool CanHandleMessage(IDotnetTest dotnetTest, Message message) { return IsAtAnAcceptableState(dotnetTest) && message.MessageType == TestMessageTypes.TestDiscoveryStart; }
protected abstract bool CanHandleMessage(IDotnetTest dotnetTest, Message message);
private static bool IsAtAnAcceptableState(IDotnetTest dotnetTest) { return(dotnetTest.State == DotnetTestState.VersionCheckCompleted || dotnetTest.State == DotnetTestState.InitialState); }
private void HandleMessage(IDotnetTest dotnetTest) { TestHostTracing.Source.TraceInformation("Starting Discovery"); DiscoverTests(dotnetTest); }
private static bool IsAtAnAcceptableState(IDotnetTest dotnetTest) { return (dotnetTest.State == DotnetTestState.TestDiscoveryStarted || dotnetTest.State == DotnetTestState.TestExecutionStarted); }
protected override bool CanHandleMessage(IDotnetTest dotnetTest, Message message) { return(dotnetTest.State == DotnetTestState.TestExecutionStarted && message.MessageType == TestMessageTypes.TestRunnerTestResult); }
private string MessageType(IDotnetTest dotnetTest) { return(dotnetTest.State == DotnetTestState.TestDiscoveryStarted ? TestMessageTypes.TestDiscoveryCompleted : TestMessageTypes.TestExecutionCompleted); }
private static bool CanHandleMessage(IDotnetTest dotnetTest, Message message) { return(dotnetTest.State == DotnetTestState.TestExecutionSentTestRunnerProcessStartInfo && message.MessageType == TestMessageTypes.TestRunnerWaitingCommand); }
private DotnetTestState NextState(IDotnetTest dotnetTest) { return(dotnetTest.State == DotnetTestState.TestDiscoveryStarted ? DotnetTestState.TestDiscoveryCompleted : DotnetTestState.TestExecutionCompleted); }
private static bool CanHandleMessage(IDotnetTest dotnetTest, Message message) { return dotnetTest.State == DotnetTestState.InitialState && TestMessageTypes.VersionCheck.Equals(message.MessageType); }
private bool CanHandleMessage(IDotnetTest dotnetTest, Message message) { return IsAtAnAcceptableState(dotnetTest) && CanAcceptMessage(message); }
private static bool CanHandleMessage(IDotnetTest dotnetTest, Message message) { return(IsAtAnAcceptableState(dotnetTest) && message.MessageType == TestMessageTypes.TestDiscoveryStart); }
private static bool CanHandleMessage(IDotnetTest dotnetTest, Message message) { return(IsAtAnAcceptableState(dotnetTest) && message.MessageType == TestMessageTypes.TestExecutionGetTestRunnerProcessStartInfo); }
protected override bool CanHandleMessage(IDotnetTest dotnetTest, Message message) { return dotnetTest.State == DotnetTestState.TestExecutionStarted && message.MessageType == TestMessageTypes.TestRunnerTestResult; }
private DotnetTestState NextState(IDotnetTest dotnetTest) { return dotnetTest.State == DotnetTestState.TestDiscoveryStarted ? DotnetTestState.TestDiscoveryCompleted : DotnetTestState.TestExecutionCompleted; }
protected override bool CanHandleMessage(IDotnetTest dotnetTest, Message message) { return(dotnetTest.State == DotnetTestState.TestDiscoveryStarted && message.MessageType == TestMessageTypes.TestRunnerTestFound); }
protected override bool CanHandleMessage(IDotnetTest dotnetTest, Message message) { return IsAtAnAcceptableState(dotnetTest) && message.MessageType == TestMessageTypes.TestRunnerTestStarted; }
private static bool IsAtAnAcceptableState(IDotnetTest dotnetTest) { return dotnetTest.State == DotnetTestState.TestExecutionSentTestRunnerProcessStartInfo || dotnetTest.State == DotnetTestState.TestExecutionStarted; }
private string MessageType(IDotnetTest dotnetTest) { return dotnetTest.State == DotnetTestState.TestDiscoveryStarted ? TestMessageTypes.TestDiscoveryCompleted : TestMessageTypes.TestExecutionCompleted; }
private static bool IsAtAnAcceptableState(IDotnetTest dotnetTest) { return(dotnetTest.State == DotnetTestState.TestExecutionSentTestRunnerProcessStartInfo || dotnetTest.State == DotnetTestState.TestExecutionStarted); }
protected override bool CanHandleMessage(IDotnetTest dotnetTest, Message message) { return dotnetTest.State == DotnetTestState.TestDiscoveryStarted && message.MessageType == TestMessageTypes.TestRunnerTestFound; }
private static bool IsAtAnAcceptableState(IDotnetTest dotnetTest) { return dotnetTest.State == DotnetTestState.VersionCheckCompleted || dotnetTest.State == DotnetTestState.InitialState; }
private bool CanHandleMessage(IDotnetTest dotnetTest, Message message) { return(IsAtAnAcceptableState(dotnetTest) && CanAcceptMessage(message)); }