Esempio n. 1
0
        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
            };
        }
Esempio n. 2
0
 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
            };
        }
 private void DoHandleMessage(IDotnetTest dotnetTest, Message message)
 {
     _adapterChannel.Send(new Message
     {
         MessageType = MessageType(dotnetTest)
     });
 }
Esempio n. 5
0
        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;
        }
Esempio n. 9
0
        public static IDotnetTest AddTestDiscoveryMessageHandlers(
            this IDotnetTest dotnetTest,
            IReportingChannel adapterChannel,
            IReportingChannelFactory reportingChannelFactory,
            ITestRunnerFactory testRunnerFactory)
        {
            dotnetTest.AddMessageHandler(
                new TestDiscoveryStartMessageHandler(testRunnerFactory, adapterChannel, reportingChannelFactory));

            return(dotnetTest);
        }
Esempio n. 10
0
        public DotnetTestState HandleMessage(IDotnetTest dotnetTest, Message message)
        {
            var nextState = DotnetTestState.NoOp;
            if (CanHandleMessage(dotnetTest, message))
            {
                HandleMessage(message);
                nextState = DotnetTestState.VersionCheckCompleted;
            }

            return nextState;
        }
Esempio n. 11
0
        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);
        }
Esempio n. 13
0
        public DotnetTestState HandleMessage(IDotnetTest dotnetTest, Message message)
        {
            var nextState = DotnetTestState.NoOp;

            if (CanHandleMessage(dotnetTest, message))
            {
                DoHandleMessage(dotnetTest, message);
                nextState = DotnetTestState.TestExecutionSentTestRunnerProcessStartInfo;
            }

            return(nextState);
        }
Esempio n. 14
0
        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;
        }
Esempio n. 16
0
        public DotnetTestState HandleMessage(IDotnetTest dotnetTest, Message message)
        {
            var nextState = DotnetTestState.NoOp;

            if (CanHandleMessage(dotnetTest, message))
            {
                HandleMessage(dotnetTest);
                nextState = DotnetTestState.TestDiscoveryStarted;
            }

            return(nextState);
        }
Esempio n. 17
0
        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;
        }
Esempio n. 19
0
        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);
        }
Esempio n. 20
0
        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);
        }
Esempio n. 21
0
        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())
                })
            });
        }
Esempio n. 23
0
        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)
            });
        }
Esempio n. 26
0
        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)
            });
        }
Esempio n. 27
0
        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;
 }
Esempio n. 31
0
 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;
 }
Esempio n. 33
0
 protected abstract bool CanHandleMessage(IDotnetTest dotnetTest, Message message);
Esempio n. 34
0
 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);
 }
Esempio n. 38
0
        private void HandleMessage(IDotnetTest dotnetTest)
        {
            TestHostTracing.Source.TraceInformation("Starting Discovery");

            DiscoverTests(dotnetTest);
        }
Esempio n. 39
0
 private string MessageType(IDotnetTest dotnetTest)
 {
     return(dotnetTest.State == DotnetTestState.TestDiscoveryStarted
         ? TestMessageTypes.TestDiscoveryCompleted
         : TestMessageTypes.TestExecutionCompleted);
 }
Esempio n. 40
0
 private static bool CanHandleMessage(IDotnetTest dotnetTest, Message message)
 {
     return(dotnetTest.State == DotnetTestState.TestExecutionSentTestRunnerProcessStartInfo &&
            message.MessageType == TestMessageTypes.TestRunnerWaitingCommand);
 }
Esempio n. 41
0
 private DotnetTestState NextState(IDotnetTest dotnetTest)
 {
     return(dotnetTest.State == DotnetTestState.TestDiscoveryStarted
         ? DotnetTestState.TestDiscoveryCompleted
         : DotnetTestState.TestExecutionCompleted);
 }
Esempio n. 42
0
 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);
 }
Esempio n. 44
0
 private static bool CanHandleMessage(IDotnetTest dotnetTest, Message message)
 {
     return(IsAtAnAcceptableState(dotnetTest) && message.MessageType == TestMessageTypes.TestDiscoveryStart);
 }
Esempio n. 45
0
 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;
 }
Esempio n. 52
0
 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;
 }
 protected abstract bool CanHandleMessage(IDotnetTest dotnetTest, Message message);
 private static bool IsAtAnAcceptableState(IDotnetTest dotnetTest)
 {
     return dotnetTest.State == DotnetTestState.VersionCheckCompleted ||
         dotnetTest.State == DotnetTestState.InitialState;
 }
Esempio n. 56
0
 private bool CanHandleMessage(IDotnetTest dotnetTest, Message message)
 {
     return(IsAtAnAcceptableState(dotnetTest) && CanAcceptMessage(message));
 }