diff --git a/src/Microsoft.DotNet.Cli.Utils/CommandFactory.cs b/src/Microsoft.DotNet.Cli.Utils/CommandFactory.cs new file mode 100644 index 0000000000..f4802113b0 --- /dev/null +++ b/src/Microsoft.DotNet.Cli.Utils/CommandFactory.cs @@ -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 args, + NuGetFramework framework = null, + string configuration = Constants.DefaultConfiguration) + { + return Command.Create(commandName, args, framework, configuration); + } + } +} diff --git a/src/Microsoft.DotNet.Cli.Utils/ICommandFactory.cs b/src/Microsoft.DotNet.Cli.Utils/ICommandFactory.cs index a90a1575dc..017d7a0d50 100644 --- a/src/Microsoft.DotNet.Cli.Utils/ICommandFactory.cs +++ b/src/Microsoft.DotNet.Cli.Utils/ICommandFactory.cs @@ -9,6 +9,9 @@ namespace Microsoft.DotNet.Cli.Utils public interface ICommandFactory { ICommand Create( - string commandName, IEnumerable args, NuGetFramework framework = null, string configuration = null); + string commandName, + IEnumerable args, + NuGetFramework framework = null, + string configuration = Constants.DefaultConfiguration); } } diff --git a/src/dotnet/commands/dotnet-test/Program.cs b/src/dotnet/commands/dotnet-test/Program.cs index 6ac79ccb0a..51ad4ae35d 100644 --- a/src/dotnet/commands/dotnet-test/Program.cs +++ b/src/dotnet/commands/dotnet-test/Program.cs @@ -130,7 +130,7 @@ private static void HandleDesignTimeMessages( var messages = new TestMessagesCollection(); using (var dotnetTest = new DotnetTest(messages, assemblyUnderTest)) { - var commandFactory = new DotNetCommandFactory(); + var commandFactory = new CommandFactory(); var testRunnerFactory = new TestRunnerFactory(GetCommandName(testRunner), commandFactory); dotnetTest diff --git a/src/dotnet/commands/dotnet-test/ReportingChannel.cs b/src/dotnet/commands/dotnet-test/ReportingChannel.cs index 2b9468bc71..6438955277 100644 --- a/src/dotnet/commands/dotnet-test/ReportingChannel.cs +++ b/src/dotnet/commands/dotnet-test/ReportingChannel.cs @@ -129,7 +129,10 @@ private void ReadMessages() public void Dispose() { - Socket.Dispose(); + if (Socket != null) + { + Socket.Dispose(); + } } } } \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-test/TestRunners/TestRunner.cs b/src/dotnet/commands/dotnet-test/TestRunners/TestRunner.cs index 7a3a14aed4..b66d39f12b 100644 --- a/src/dotnet/commands/dotnet-test/TestRunners/TestRunner.cs +++ b/src/dotnet/commands/dotnet-test/TestRunners/TestRunner.cs @@ -51,9 +51,10 @@ private ICommand CreateTestRunnerCommand() var commandArgs = _argumentsBuilder.BuildArguments(); return _commandFactory.Create( - _testRunner, + $"dotnet-{_testRunner}", commandArgs, - new NuGetFramework("DNXCore", Version.Parse("5.0"))); + new NuGetFramework("DNXCore", Version.Parse("5.0")), + Constants.DefaultConfiguration); } } } diff --git a/test/dotnet-test.UnitTests/GivenATestRunner.cs b/test/dotnet-test.UnitTests/GivenATestRunner.cs index d7a095c8de..fd8496f27e 100644 --- a/test/dotnet-test.UnitTests/GivenATestRunner.cs +++ b/test/dotnet-test.UnitTests/GivenATestRunner.cs @@ -38,10 +38,10 @@ public GivenATestRunner() _commandFactoryMock = new Mock(); _commandFactoryMock.Setup(c => c.Create( - _runner, + $"dotnet-{_runner}", _testRunnerArguments, new NuGetFramework("DNXCore", Version.Parse("5.0")), - null)).Returns(_commandMock.Object).Verifiable(); + Constants.DefaultConfiguration)).Returns(_commandMock.Object).Verifiable(); } [Fact]