Skip to content

Commit

Permalink
Adding a new factory that creates the command as is, without adding t…
Browse files Browse the repository at this point in the history
…he 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.
  • Loading branch information
livarcocc committed Feb 26, 2016
1 parent 178d05a commit 5b5d2cd
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 7 deletions.
20 changes: 20 additions & 0 deletions src/Microsoft.DotNet.Cli.Utils/CommandFactory.cs
Original file line number Diff line number Diff line change
@@ -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);
}
}
}
5 changes: 4 additions & 1 deletion src/Microsoft.DotNet.Cli.Utils/ICommandFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ namespace Microsoft.DotNet.Cli.Utils
public interface ICommandFactory
{
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);
}
}
2 changes: 1 addition & 1 deletion src/dotnet/commands/dotnet-test/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion src/dotnet/commands/dotnet-test/ReportingChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,10 @@ private void ReadMessages()

public void Dispose()
{
Socket.Dispose();
if (Socket != null)
{
Socket.Dispose();
}
}
}
}
5 changes: 3 additions & 2 deletions src/dotnet/commands/dotnet-test/TestRunners/TestRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
4 changes: 2 additions & 2 deletions test/dotnet-test.UnitTests/GivenATestRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ public GivenATestRunner()

_commandFactoryMock = new Mock<ICommandFactory>();
_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]
Expand Down

0 comments on commit 5b5d2cd

Please sign in to comment.