Changing from serializing ProcessStartInfo to our own TestStartInfo class, because serializing ProcessStartInfo doesn't really work cross-platform due to unsupported properties.

This commit is contained in:
Livar Cunha 2016-03-01 21:53:51 -08:00
parent 4108920510
commit 9953ab48b3
6 changed files with 31 additions and 16 deletions

View file

@ -1,16 +1,19 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved. // 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. // Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System.Diagnostics;
using Microsoft.DotNet.Cli.Utils; using Microsoft.DotNet.Cli.Utils;
namespace Microsoft.DotNet.Tools.Test namespace Microsoft.DotNet.Tools.Test
{ {
public static class CommandTestRunnerExtensions public static class CommandTestRunnerExtensions
{ {
public static ProcessStartInfo ToProcessStartInfo(this ICommand command) public static TestStartInfo ToTestStartInfo(this ICommand command)
{ {
return new ProcessStartInfo(command.CommandName, command.CommandArgs); return new TestStartInfo
{
FileName = command.CommandName,
Arguments = command.CommandArgs
};
} }
} }
} }

View file

@ -1,16 +1,12 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved. // 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. // Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System.Collections.Generic;
using System.Diagnostics;
using Microsoft.Extensions.Testing.Abstractions;
namespace Microsoft.DotNet.Tools.Test namespace Microsoft.DotNet.Tools.Test
{ {
public interface ITestRunner public interface ITestRunner
{ {
void RunTestCommand(); void RunTestCommand();
ProcessStartInfo GetProcessStartInfo(); TestStartInfo GetProcessStartInfo();
} }
} }

View file

@ -29,11 +29,11 @@ namespace Microsoft.DotNet.Tools.Test
ExecuteRunnerCommand(); ExecuteRunnerCommand();
} }
public ProcessStartInfo GetProcessStartInfo() public TestStartInfo GetProcessStartInfo()
{ {
var command = CreateTestRunnerCommand(); var command = CreateTestRunnerCommand();
return command.ToProcessStartInfo(); return command.ToTestStartInfo();
} }
private void ExecuteRunnerCommand() private void ExecuteRunnerCommand()

View file

@ -0,0 +1,12 @@
// 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.
namespace Microsoft.DotNet.Tools.Test
{
public class TestStartInfo
{
public string FileName { get; set; }
public string Arguments { get; set; }
}
}

View file

@ -19,7 +19,7 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
private GetTestRunnerProcessStartInfoMessageHandler _testGetTestRunnerProcessStartInfoMessageHandler; private GetTestRunnerProcessStartInfoMessageHandler _testGetTestRunnerProcessStartInfoMessageHandler;
private Message _validMessage; private Message _validMessage;
private ProcessStartInfo _processStartInfo; private TestStartInfo _testStartInfo;
private Mock<ITestRunner> _testRunnerMock; private Mock<ITestRunner> _testRunnerMock;
private Mock<ITestRunnerFactory> _testRunnerFactoryMock; private Mock<ITestRunnerFactory> _testRunnerFactoryMock;
@ -42,10 +42,14 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
_dotnetTestMock.Setup(d => d.State).Returns(DotnetTestState.VersionCheckCompleted); _dotnetTestMock.Setup(d => d.State).Returns(DotnetTestState.VersionCheckCompleted);
_dotnetTestMock.Setup(d => d.PathToAssemblyUnderTest).Returns(AssemblyUnderTest); _dotnetTestMock.Setup(d => d.PathToAssemblyUnderTest).Returns(AssemblyUnderTest);
_processStartInfo = new ProcessStartInfo("runner", "arguments"); _testStartInfo = new TestStartInfo
{
FileName = "runner",
Arguments = "arguments"
};
_testRunnerMock = new Mock<ITestRunner>(); _testRunnerMock = new Mock<ITestRunner>();
_testRunnerMock.Setup(t => t.GetProcessStartInfo()).Returns(_processStartInfo); _testRunnerMock.Setup(t => t.GetProcessStartInfo()).Returns(_testStartInfo);
_testRunnerFactoryMock = new Mock<ITestRunnerFactory>(); _testRunnerFactoryMock = new Mock<ITestRunnerFactory>();
_testRunnerFactoryMock _testRunnerFactoryMock
@ -128,8 +132,8 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
{ {
_adapterChannelMock.Setup(r => r.Send(It.Is<Message>(m => _adapterChannelMock.Setup(r => r.Send(It.Is<Message>(m =>
m.MessageType == TestMessageTypes.TestExecutionTestRunnerProcessStartInfo && m.MessageType == TestMessageTypes.TestExecutionTestRunnerProcessStartInfo &&
m.Payload.ToObject<ProcessStartInfo>().FileName == _processStartInfo.FileName && m.Payload.ToObject<ProcessStartInfo>().FileName == _testStartInfo.FileName &&
m.Payload.ToObject<ProcessStartInfo>().Arguments == _processStartInfo.Arguments))).Verifiable(); m.Payload.ToObject<ProcessStartInfo>().Arguments == _testStartInfo.Arguments))).Verifiable();
_testGetTestRunnerProcessStartInfoMessageHandler.HandleMessage( _testGetTestRunnerProcessStartInfoMessageHandler.HandleMessage(
_dotnetTestMock.Object, _dotnetTestMock.Object,

View file

@ -19,7 +19,7 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
dotnetTestMessageScenario.TestRunnerMock dotnetTestMessageScenario.TestRunnerMock
.Setup(t => t.GetProcessStartInfo()) .Setup(t => t.GetProcessStartInfo())
.Returns(new ProcessStartInfo()) .Returns(new TestStartInfo())
.Verifiable(); .Verifiable();
dotnetTestMessageScenario.AdapterChannelMock dotnetTestMessageScenario.AdapterChannelMock