Adding a new factory that creates the command as is, without adding the dotnet to it. We need it so that the runner can pass dotnet-test-xunit and get back the final corehost command, which is the right one for VS to use and attach to.

This commit is contained in:
Livar Cunha 2016-02-26 14:31:53 -08:00
parent 178d05a5ec
commit 5b5d2cd31a
6 changed files with 34 additions and 7 deletions

View file

@ -0,0 +1,20 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System.Collections.Generic;
using NuGet.Frameworks;
namespace Microsoft.DotNet.Cli.Utils
{
public class CommandFactory : ICommandFactory
{
public ICommand Create(
string commandName,
IEnumerable<string> args,
NuGetFramework framework = null,
string configuration = Constants.DefaultConfiguration)
{
return Command.Create(commandName, args, framework, configuration);
}
}
}

View file

@ -9,6 +9,9 @@ namespace Microsoft.DotNet.Cli.Utils
public interface ICommandFactory public interface ICommandFactory
{ {
ICommand Create( ICommand Create(
string commandName, IEnumerable<string> args, NuGetFramework framework = null, string configuration = null); string commandName,
IEnumerable<string> args,
NuGetFramework framework = null,
string configuration = Constants.DefaultConfiguration);
} }
} }

View file

@ -130,7 +130,7 @@ namespace Microsoft.DotNet.Tools.Test
var messages = new TestMessagesCollection(); var messages = new TestMessagesCollection();
using (var dotnetTest = new DotnetTest(messages, assemblyUnderTest)) using (var dotnetTest = new DotnetTest(messages, assemblyUnderTest))
{ {
var commandFactory = new DotNetCommandFactory(); var commandFactory = new CommandFactory();
var testRunnerFactory = new TestRunnerFactory(GetCommandName(testRunner), commandFactory); var testRunnerFactory = new TestRunnerFactory(GetCommandName(testRunner), commandFactory);
dotnetTest dotnetTest

View file

@ -129,7 +129,10 @@ namespace Microsoft.DotNet.Tools.Test
public void Dispose() public void Dispose()
{ {
Socket.Dispose(); if (Socket != null)
{
Socket.Dispose();
}
} }
} }
} }

View file

@ -51,9 +51,10 @@ namespace Microsoft.DotNet.Tools.Test
var commandArgs = _argumentsBuilder.BuildArguments(); var commandArgs = _argumentsBuilder.BuildArguments();
return _commandFactory.Create( return _commandFactory.Create(
_testRunner, $"dotnet-{_testRunner}",
commandArgs, commandArgs,
new NuGetFramework("DNXCore", Version.Parse("5.0"))); new NuGetFramework("DNXCore", Version.Parse("5.0")),
Constants.DefaultConfiguration);
} }
} }
} }

View file

@ -38,10 +38,10 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
_commandFactoryMock = new Mock<ICommandFactory>(); _commandFactoryMock = new Mock<ICommandFactory>();
_commandFactoryMock.Setup(c => c.Create( _commandFactoryMock.Setup(c => c.Create(
_runner, $"dotnet-{_runner}",
_testRunnerArguments, _testRunnerArguments,
new NuGetFramework("DNXCore", Version.Parse("5.0")), new NuGetFramework("DNXCore", Version.Parse("5.0")),
null)).Returns(_commandMock.Object).Verifiable(); Constants.DefaultConfiguration)).Returns(_commandMock.Object).Verifiable();
} }
[Fact] [Fact]