Skip to content

Commit

Permalink
Vstest.console Should not message to Testhost process if it has exited (
Browse files Browse the repository at this point in the history
#1994)

* Do not send TestRun Cancel/Abort, if Testhost process has exited

* tests
  • Loading branch information
mayankbansal018 committed Apr 24, 2019
1 parent f94af06 commit 7dd4ef7
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
Expand Up @@ -320,6 +320,12 @@ public void StartTestRun(TestRunCriteriaWithTests runCriteria, ITestRunEventsHan
/// <inheritdoc />
public void SendTestRunCancel()
{
if (this.IsOperationComplete())
{
EqtTrace.Verbose("TestRequestSender: SendTestRunCancel: Operation is already complete. Skip error message.");
return;
}

if (EqtTrace.IsVerboseEnabled)
{
EqtTrace.Verbose("TestRequestSender.SendTestRunCancel: Sending test run cancel.");
Expand All @@ -331,6 +337,12 @@ public void SendTestRunCancel()
/// <inheritdoc />
public void SendTestRunAbort()
{
if (this.IsOperationComplete())
{
EqtTrace.Verbose("TestRequestSender: SendTestRunAbort: Operation is already complete. Skip error message.");
return;
}

if (EqtTrace.IsVerboseEnabled)
{
EqtTrace.Verbose("TestRequestSender.SendTestRunAbort: Sending test run abort.");
Expand Down
Expand Up @@ -178,6 +178,30 @@ public void EndSessionShouldNotSendSessionEndMessageIfTestHostProcessExited()
this.mockDataSerializer.Verify(ds => ds.SerializeMessage(MessageType.SessionEnd), Times.Once);
}

[TestMethod]
public void EndSessionShouldNotSendTestRunCancelMessageIfClientDisconnected()
{
this.SetupFakeCommunicationChannel();
this.testRequestSender.DiscoverTests(new DiscoveryCriteria(), this.mockDiscoveryEventsHandler.Object);
this.RaiseClientDisconnectedEvent();

this.testRequestSender.SendTestRunCancel();

this.mockChannel.Verify(mockChannel => mockChannel.Send(MessageType.CancelTestRun), Times.Never);
}

[TestMethod]
public void EndSessionShouldNotSendTestRunAbortMessageIfClientDisconnected()
{
this.SetupFakeCommunicationChannel();
this.testRequestSender.DiscoverTests(new DiscoveryCriteria(), this.mockDiscoveryEventsHandler.Object);
this.RaiseClientDisconnectedEvent();

this.testRequestSender.SendTestRunAbort();

this.mockChannel.Verify(mockChannel => mockChannel.Send(MessageType.CancelTestRun), Times.Never);
}

[DataTestMethod]
[DataRow("")]
[DataRow(" ")]
Expand Down

0 comments on commit 7dd4ef7

Please sign in to comment.