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:
parent
4108920510
commit
9953ab48b3
6 changed files with 31 additions and 16 deletions
|
@ -1,16 +1,19 @@
|
|||
// 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.Diagnostics;
|
||||
using Microsoft.DotNet.Cli.Utils;
|
||||
|
||||
namespace Microsoft.DotNet.Tools.Test
|
||||
{
|
||||
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
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +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.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using Microsoft.Extensions.Testing.Abstractions;
|
||||
|
||||
namespace Microsoft.DotNet.Tools.Test
|
||||
{
|
||||
public interface ITestRunner
|
||||
{
|
||||
void RunTestCommand();
|
||||
|
||||
ProcessStartInfo GetProcessStartInfo();
|
||||
TestStartInfo GetProcessStartInfo();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,11 +29,11 @@ namespace Microsoft.DotNet.Tools.Test
|
|||
ExecuteRunnerCommand();
|
||||
}
|
||||
|
||||
public ProcessStartInfo GetProcessStartInfo()
|
||||
public TestStartInfo GetProcessStartInfo()
|
||||
{
|
||||
var command = CreateTestRunnerCommand();
|
||||
|
||||
return command.ToProcessStartInfo();
|
||||
return command.ToTestStartInfo();
|
||||
}
|
||||
|
||||
private void ExecuteRunnerCommand()
|
||||
|
|
12
src/dotnet/commands/dotnet-test/TestStartInfo.cs
Normal file
12
src/dotnet/commands/dotnet-test/TestStartInfo.cs
Normal 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; }
|
||||
}
|
||||
}
|
|
@ -19,7 +19,7 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
|
|||
|
||||
private GetTestRunnerProcessStartInfoMessageHandler _testGetTestRunnerProcessStartInfoMessageHandler;
|
||||
private Message _validMessage;
|
||||
private ProcessStartInfo _processStartInfo;
|
||||
private TestStartInfo _testStartInfo;
|
||||
|
||||
private Mock<ITestRunner> _testRunnerMock;
|
||||
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.PathToAssemblyUnderTest).Returns(AssemblyUnderTest);
|
||||
|
||||
_processStartInfo = new ProcessStartInfo("runner", "arguments");
|
||||
_testStartInfo = new TestStartInfo
|
||||
{
|
||||
FileName = "runner",
|
||||
Arguments = "arguments"
|
||||
};
|
||||
|
||||
_testRunnerMock = new Mock<ITestRunner>();
|
||||
_testRunnerMock.Setup(t => t.GetProcessStartInfo()).Returns(_processStartInfo);
|
||||
_testRunnerMock.Setup(t => t.GetProcessStartInfo()).Returns(_testStartInfo);
|
||||
|
||||
_testRunnerFactoryMock = new Mock<ITestRunnerFactory>();
|
||||
_testRunnerFactoryMock
|
||||
|
@ -128,8 +132,8 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
|
|||
{
|
||||
_adapterChannelMock.Setup(r => r.Send(It.Is<Message>(m =>
|
||||
m.MessageType == TestMessageTypes.TestExecutionTestRunnerProcessStartInfo &&
|
||||
m.Payload.ToObject<ProcessStartInfo>().FileName == _processStartInfo.FileName &&
|
||||
m.Payload.ToObject<ProcessStartInfo>().Arguments == _processStartInfo.Arguments))).Verifiable();
|
||||
m.Payload.ToObject<ProcessStartInfo>().FileName == _testStartInfo.FileName &&
|
||||
m.Payload.ToObject<ProcessStartInfo>().Arguments == _testStartInfo.Arguments))).Verifiable();
|
||||
|
||||
_testGetTestRunnerProcessStartInfoMessageHandler.HandleMessage(
|
||||
_dotnetTestMock.Object,
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
|
|||
|
||||
dotnetTestMessageScenario.TestRunnerMock
|
||||
.Setup(t => t.GetProcessStartInfo())
|
||||
.Returns(new ProcessStartInfo())
|
||||
.Returns(new TestStartInfo())
|
||||
.Verifiable();
|
||||
|
||||
dotnetTestMessageScenario.AdapterChannelMock
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue