예제 #1
0
        private void HandleDesignTimeMessages(DotnetTestParams dotnetTestParams)
        {
            var reportingChannelFactory = new ReportingChannelFactory();
            var adapterChannel          = reportingChannelFactory.CreateAdapterChannel(dotnetTestParams.Port.Value);

            try
            {
                var pathToAssemblyUnderTest = _assemblyUnderTest;
                var messages = new TestMessagesCollection();
                using (var dotnetTest = new DotnetTest(messages, pathToAssemblyUnderTest))
                {
                    var testRunnerFactory =
                        new TestRunnerFactory(_testRunnerNameResolver.ResolveTestRunner(), _commandFactory);

                    dotnetTest
                    .AddNonSpecificMessageHandlers(messages, adapterChannel)
                    .AddTestDiscoveryMessageHandlers(adapterChannel, reportingChannelFactory, testRunnerFactory)
                    .AddTestRunMessageHandlers(adapterChannel, reportingChannelFactory, testRunnerFactory)
                    .AddTestRunnnersMessageHandlers(adapterChannel, reportingChannelFactory);

                    dotnetTest.StartListeningTo(adapterChannel);

                    adapterChannel.Connect();

                    dotnetTest.StartHandlingMessages();
                }
            }
            catch (Exception ex)
            {
                adapterChannel.SendError(ex);
            }
        }
예제 #2
0
 public DotnetTestMessageScenario()
 {
     _messages = new TestMessagesCollection();
     DotnetTestUnderTest = new DotnetTest(_messages, AssemblyUnderTest);
     TestRunnerChannelMock = new Mock<IReportingChannel>();
     TestRunnerMock = new Mock<ITestRunner>();
     AdapterChannelMock = new Mock<IReportingChannel>();
 }
예제 #3
0
파일: Program.cs 프로젝트: nosoq/cli
        private static void HandleDesignTimeMessages(
            ProjectContext projectContext,
            string testRunner,
            int port,
            string configuration,
            string outputPath)
        {
            var reportingChannelFactory = new ReportingChannelFactory();
            var adapterChannel          = reportingChannelFactory.CreateAdapterChannel(port);

            try
            {
                var assemblyUnderTest = GetAssemblyUnderTest(projectContext, configuration, outputPath);
                var messages          = new TestMessagesCollection();
                using (var dotnetTest = new DotnetTest(messages, assemblyUnderTest))
                {
                    var commandFactory =
                        new ProjectDependenciesCommandFactory(
                            projectContext.TargetFramework,
                            configuration,
                            outputPath,
                            projectContext.ProjectDirectory);

                    var testRunnerFactory = new TestRunnerFactory(GetCommandName(testRunner), commandFactory);

                    dotnetTest
                    .AddNonSpecificMessageHandlers(messages, adapterChannel)
                    .AddTestDiscoveryMessageHandlers(adapterChannel, reportingChannelFactory, testRunnerFactory)
                    .AddTestRunMessageHandlers(adapterChannel, reportingChannelFactory, testRunnerFactory)
                    .AddTestRunnnersMessageHandlers(adapterChannel, reportingChannelFactory);

                    dotnetTest.StartListeningTo(adapterChannel);

                    adapterChannel.Accept();

                    dotnetTest.StartHandlingMessages();
                }
            }
            catch (Exception ex)
            {
                adapterChannel.SendError(ex);
            }
        }
예제 #4
0
        private static void HandleDesignTimeMessages(
            ProjectContext projectContext,
            DotnetTestParams dotnetTestParams)
        {
            var reportingChannelFactory = new ReportingChannelFactory();
            var adapterChannel          = reportingChannelFactory.CreateAdapterChannel(dotnetTestParams.Port.Value);

            try
            {
                var pathToAssemblyUnderTest = new AssemblyUnderTest(projectContext, dotnetTestParams).Path;
                var messages = new TestMessagesCollection();
                using (var dotnetTest = new DotnetTest(messages, pathToAssemblyUnderTest))
                {
                    var commandFactory =
                        new ProjectDependenciesCommandFactory(
                            projectContext.TargetFramework,
                            dotnetTestParams.Config,
                            dotnetTestParams.Output,
                            dotnetTestParams.BuildBasePath,
                            projectContext.ProjectDirectory);

                    var testRunnerFactory =
                        new TestRunnerFactory(GetCommandName(projectContext.ProjectFile.TestRunner), commandFactory);

                    dotnetTest
                    .AddNonSpecificMessageHandlers(messages, adapterChannel)
                    .AddTestDiscoveryMessageHandlers(adapterChannel, reportingChannelFactory, testRunnerFactory)
                    .AddTestRunMessageHandlers(adapterChannel, reportingChannelFactory, testRunnerFactory)
                    .AddTestRunnnersMessageHandlers(adapterChannel, reportingChannelFactory);

                    dotnetTest.StartListeningTo(adapterChannel);

                    adapterChannel.Connect();

                    dotnetTest.StartHandlingMessages();
                }
            }
            catch (Exception ex)
            {
                adapterChannel.SendError(ex);
            }
        }
예제 #5
0
        private static void HandleDesignTimeMessages(
            ProjectContext projectContext,
            DotnetTestParams dotnetTestParams)
        {
            var reportingChannelFactory = new ReportingChannelFactory();
            var adapterChannel = reportingChannelFactory.CreateAdapterChannel(dotnetTestParams.Port.Value);

            try
            {
                var pathToAssemblyUnderTest = new AssemblyUnderTest(projectContext, dotnetTestParams).Path;
                var messages = new TestMessagesCollection();
                using (var dotnetTest = new DotnetTest(messages, pathToAssemblyUnderTest))
                {
                    var commandFactory =
                        new ProjectDependenciesCommandFactory(
                            projectContext.TargetFramework,
                            dotnetTestParams.Config,
                            dotnetTestParams.Output,
                            dotnetTestParams.BuildBasePath,
                            projectContext.ProjectDirectory);

                    var testRunnerFactory =
                        new TestRunnerFactory(GetCommandName(projectContext.ProjectFile.TestRunner), commandFactory);

                    dotnetTest
                        .AddNonSpecificMessageHandlers(messages, adapterChannel)
                        .AddTestDiscoveryMessageHandlers(adapterChannel, reportingChannelFactory, testRunnerFactory)
                        .AddTestRunMessageHandlers(adapterChannel, reportingChannelFactory, testRunnerFactory)
                        .AddTestRunnnersMessageHandlers(adapterChannel, reportingChannelFactory);

                    dotnetTest.StartListeningTo(adapterChannel);

                    adapterChannel.Connect();

                    dotnetTest.StartHandlingMessages();
                }
            }
            catch (Exception ex)
            {
                adapterChannel.SendError(ex);
            }
        }
예제 #6
0
        public GivenADotnetTestApp()
        {
            _noOpMessageHandlerMock = new Mock<IDotnetTestMessageHandler>();
            _noOpMessageHandlerMock
                .Setup(mh => mh.HandleMessage(It.IsAny<DotnetTest>(), It.IsAny<Message>()))
                .Returns(DotnetTestState.NoOp)
                .Verifiable();

            _realMessageHandlerMock = new Mock<IDotnetTestMessageHandler>();
            _realMessageHandlerMock
                .Setup(mh => mh.HandleMessage(It.IsAny<DotnetTest>(), It.Is<Message>(m => m.MessageType == "Test message")))
                .Returns(DotnetTestState.VersionCheckCompleted).Callback(() =>
                _reportingChannelMock.Raise(r => r.MessageReceived += null, _dotnetTest, new Message
                {
                    MessageType = TestMessageTypes.TestSessionTerminate
                }));

            _reportingChannelMock = new Mock<IReportingChannel>();
            _unknownMessageHandlerMock = new Mock<IDotnetTestMessageHandler>();
            _unknownMessageHandlerMock
                .Setup(mh => mh.HandleMessage(It.IsAny<DotnetTest>(), It.IsAny<Message>()))
                .Throws<InvalidOperationException>();

            var testMessagesCollection = new TestMessagesCollection();
            _dotnetTest = new DotnetTest(testMessagesCollection, AssemblyUnderTest)
            {
                TestSessionTerminateMessageHandler = new TestSessionTerminateMessageHandler(testMessagesCollection),
                UnknownMessageHandler = _unknownMessageHandlerMock.Object
            };

            _dotnetTest.StartListeningTo(_reportingChannelMock.Object);

            _reportingChannelMock.Raise(r => r.MessageReceived += null, _dotnetTest, new Message
            {
                MessageType = "Test message"
            });
        }
예제 #7
0
파일: Program.cs 프로젝트: cdmihai/cli
        private static void HandleDesignTimeMessages(
            ProjectContext projectContext,
            string testRunner,
            int port,
            string configuration)
        {
            var reportingChannelFactory = new ReportingChannelFactory();
            var adapterChannel = reportingChannelFactory.CreateChannelWithPort(port);

            try
            {
                var assemblyUnderTest = projectContext.GetOutputPaths(configuration).CompilationFiles.Assembly;
                var messages = new TestMessagesCollection();
                using (var dotnetTest = new DotnetTest(messages, assemblyUnderTest))
                {
                    var commandFactory = new CommandFactory();
                    var testRunnerFactory = new TestRunnerFactory(GetCommandName(testRunner), commandFactory);

                    dotnetTest
                        .AddNonSpecificMessageHandlers(messages, adapterChannel)
                        .AddTestDiscoveryMessageHandlers(adapterChannel, reportingChannelFactory, testRunnerFactory)
                        .AddTestRunMessageHandlers(adapterChannel, reportingChannelFactory, testRunnerFactory)
                        .AddTestRunnnersMessageHandlers(adapterChannel);

                    dotnetTest.StartListeningTo(adapterChannel);

                    adapterChannel.Accept();

                    dotnetTest.StartHandlingMessages();
                }
            }
            catch (Exception ex)
            {
                adapterChannel.SendError(ex);
            }
        }
예제 #8
0
파일: Program.cs 프로젝트: ericstj/cli
        private static void HandleDesignTimeMessages(
            ProjectContext projectContext,
            string testRunner,
            int port,
            string configuration,
            string outputPath)
        {
            var reportingChannelFactory = new ReportingChannelFactory();
            var adapterChannel = reportingChannelFactory.CreateAdapterChannel(port);

            try
            {
                var assemblyUnderTest = GetAssemblyUnderTest(projectContext, configuration, outputPath);
                var messages = new TestMessagesCollection();
                using (var dotnetTest = new DotnetTest(messages, assemblyUnderTest))
                {
                    var commandFactory = 
                        new ProjectDependenciesCommandFactory(
                            projectContext.TargetFramework, 
                            configuration, 
                            outputPath,
                            projectContext.ProjectDirectory);
                        
                    var testRunnerFactory = new TestRunnerFactory(GetCommandName(testRunner), commandFactory);

                    dotnetTest
                        .AddNonSpecificMessageHandlers(messages, adapterChannel)
                        .AddTestDiscoveryMessageHandlers(adapterChannel, reportingChannelFactory, testRunnerFactory)
                        .AddTestRunMessageHandlers(adapterChannel, reportingChannelFactory, testRunnerFactory)
                        .AddTestRunnnersMessageHandlers(adapterChannel, reportingChannelFactory);

                    dotnetTest.StartListeningTo(adapterChannel);

                    adapterChannel.Accept();

                    dotnetTest.StartHandlingMessages();
                }
            }
            catch (Exception ex)
            {
                adapterChannel.SendError(ex);
            }
        }