Making the version check an optional message for test discovery and test run.
This commit is contained in:
parent
7407a898e0
commit
252eb4371f
4 changed files with 43 additions and 7 deletions
|
@ -55,8 +55,14 @@ namespace Microsoft.DotNet.Tools.Test
|
||||||
|
|
||||||
private static bool CanHandleMessage(IDotnetTest dotnetTest, Message message)
|
private static bool CanHandleMessage(IDotnetTest dotnetTest, Message message)
|
||||||
{
|
{
|
||||||
return dotnetTest.State == DotnetTestState.VersionCheckCompleted &&
|
return IsAtAnAcceptableState(dotnetTest) &&
|
||||||
message.MessageType == TestMessageTypes.TestExecutionGetTestRunnerProcessStartInfo;
|
message.MessageType == TestMessageTypes.TestExecutionGetTestRunnerProcessStartInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static bool IsAtAnAcceptableState(IDotnetTest dotnetTest)
|
||||||
|
{
|
||||||
|
return dotnetTest.State == DotnetTestState.VersionCheckCompleted ||
|
||||||
|
dotnetTest.State == DotnetTestState.InitialState;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,8 +68,13 @@ namespace Microsoft.DotNet.Cli.Tools.Test
|
||||||
|
|
||||||
private static bool CanHandleMessage(IDotnetTest dotnetTest, Message message)
|
private static bool CanHandleMessage(IDotnetTest dotnetTest, Message message)
|
||||||
{
|
{
|
||||||
return dotnetTest.State == DotnetTestState.VersionCheckCompleted &&
|
return IsAtAnAcceptableState(dotnetTest) && message.MessageType == TestMessageTypes.TestDiscoveryStart;
|
||||||
message.MessageType == TestMessageTypes.TestDiscoveryStart;
|
}
|
||||||
|
|
||||||
|
private static bool IsAtAnAcceptableState(IDotnetTest dotnetTest)
|
||||||
|
{
|
||||||
|
return (dotnetTest.State == DotnetTestState.VersionCheckCompleted ||
|
||||||
|
dotnetTest.State == DotnetTestState.InitialState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,7 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void It_returns_NoOp_if_the_dotnet_test_state_is_not_VersionCheckCompleted()
|
public void It_returns_NoOp_if_the_dotnet_test_state_is_not_VersionCheckCompleted_or_InitialState()
|
||||||
{
|
{
|
||||||
var dotnetTestMock = new Mock<IDotnetTest>();
|
var dotnetTestMock = new Mock<IDotnetTest>();
|
||||||
dotnetTestMock.Setup(d => d.State).Returns(DotnetTestState.Terminated);
|
dotnetTestMock.Setup(d => d.State).Returns(DotnetTestState.Terminated);
|
||||||
|
@ -84,7 +84,19 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void It_returns_TestDiscoveryCompleted_when_it_handles_the_message()
|
public void It_returns_TestDiscoveryCompleted_when_it_handles_the_message_and_current_state_is_InitialState()
|
||||||
|
{
|
||||||
|
var dotnetTestMock = new Mock<IDotnetTest>();
|
||||||
|
dotnetTestMock.Setup(d => d.State).Returns(DotnetTestState.InitialState);
|
||||||
|
|
||||||
|
var nextState =
|
||||||
|
_testDiscoveryStartMessageHandler.HandleMessage(dotnetTestMock.Object, _validMessage);
|
||||||
|
|
||||||
|
nextState.Should().Be(DotnetTestState.TestDiscoveryStarted);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void It_returns_TestDiscoveryCompleted_when_it_handles_the_message_and_current_state_is_VersionCheckCompleted()
|
||||||
{
|
{
|
||||||
var nextState =
|
var nextState =
|
||||||
_testDiscoveryStartMessageHandler.HandleMessage(_dotnetTestAtVersionCheckCompletedState, _validMessage);
|
_testDiscoveryStartMessageHandler.HandleMessage(_dotnetTestAtVersionCheckCompletedState, _validMessage);
|
||||||
|
|
|
@ -68,7 +68,7 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void It_returns_NoOp_if_the_dotnet_test_state_is_not_VersionCheckCompleted()
|
public void It_returns_NoOp_if_the_dotnet_test_state_is_not_VersionCheckCompleted_or_InitialState()
|
||||||
{
|
{
|
||||||
var dotnetTestMock = new Mock<IDotnetTest>();
|
var dotnetTestMock = new Mock<IDotnetTest>();
|
||||||
dotnetTestMock.Setup(d => d.State).Returns(DotnetTestState.Terminated);
|
dotnetTestMock.Setup(d => d.State).Returns(DotnetTestState.Terminated);
|
||||||
|
@ -91,7 +91,20 @@ namespace Microsoft.Dotnet.Tools.Test.Tests
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void It_returns_TestExecutionSentTestRunnerProcessStartInfo_when_it_handles_the_message()
|
public void It_returns_TestExecutionSentTestRunnerProcessStartInfo_when_it_handles_the_message_and_current_state_is_InitialState()
|
||||||
|
{
|
||||||
|
var dotnetTestMock = new Mock<IDotnetTest>();
|
||||||
|
dotnetTestMock.Setup(d => d.State).Returns(DotnetTestState.InitialState);
|
||||||
|
|
||||||
|
var nextState = _testGetTestRunnerProcessStartInfoMessageHandler.HandleMessage(
|
||||||
|
dotnetTestMock.Object,
|
||||||
|
_validMessage);
|
||||||
|
|
||||||
|
nextState.Should().Be(DotnetTestState.TestExecutionSentTestRunnerProcessStartInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void It_returns_TestExecutionSentTestRunnerProcessStartInfo_when_it_handles_the_message_and_current_state_is_VersionCheckCompleted()
|
||||||
{
|
{
|
||||||
var nextState = _testGetTestRunnerProcessStartInfoMessageHandler.HandleMessage(
|
var nextState = _testGetTestRunnerProcessStartInfoMessageHandler.HandleMessage(
|
||||||
_dotnetTestMock.Object,
|
_dotnetTestMock.Object,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue