From b5694d4ba035ae1aebd1ef275015d2b94fd43db8 Mon Sep 17 00:00:00 2001 From: mayankbansal018 Date: Wed, 4 Oct 2017 12:58:29 +0530 Subject: [PATCH] fix test (#1157) * fix test * assert that "ListenAndReportTestResults" did complete --- .../TestRequestSenderTests.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/TestRequestSenderTests.cs b/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/TestRequestSenderTests.cs index 0835b89955..8d9d3cd10f 100644 --- a/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/TestRequestSenderTests.cs +++ b/test/Microsoft.TestPlatform.CommunicationUtilities.UnitTests/TestRequestSenderTests.cs @@ -472,15 +472,18 @@ public void StartTestRunShouldCallHandleLogMessageOnTestMessage() () => { this.mockDataSerializer.Setup(ds => ds.DeserializeMessage(It.IsAny())).Returns(completeMessage); - this.mockDataSerializer.Setup(ds => ds.DeserializePayload(completeMessage)).Returns(completePayload); - waitHandle.Set(); + this.mockDataSerializer.Setup(ds => ds.DeserializePayload(completeMessage)).Callback(() => { waitHandle.Set(); }) + .Returns(completePayload); }); this.testRequestSender.StartTestRun(runCriteria, mockHandler.Object); waitHandle.WaitOne(); this.mockCommunicationManager.Verify(mc => mc.SendMessage(MessageType.StartTestExecutionWithSources, runCriteria, this.protocolConfig.Version), Times.Once); - this.mockDataSerializer.Verify(ds => ds.DeserializeMessage(It.IsAny()), Times.Exactly(2)); + this.mockDataSerializer.Verify(ds => ds.DeserializeMessage(It.IsAny()), Times.AtLeast(2)); + + // Asserting that 'StartTestRun" should have been completed, & invoked only once + this.mockDataSerializer.Verify(ds => ds.DeserializePayload(completeMessage), Times.Exactly(1)); mockHandler.Verify(mh => mh.HandleLogMessage(payload.MessageLevel, payload.Message), Times.Once); mockHandler.Verify(mh => mh.HandleRawMessage(rawMessage), Times.AtLeastOnce); }