-
Notifications
You must be signed in to change notification settings - Fork 323
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
56 additions
and
0 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
...m.Client.UnitTests/MultiTestRunFinalization/MultiTestRunFinalizationEventsHandlerTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
namespace Microsoft.TestPlatform.Client.UnitTests.MultiTestRunFinalization | ||
{ | ||
using Microsoft.VisualStudio.TestPlatform.Client.MultiTestRunFinalization; | ||
using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; | ||
using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; | ||
using Microsoft.VisualStudio.TestPlatform.ObjectModel; | ||
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; | ||
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
using Moq; | ||
|
||
[TestClass] | ||
public class MultiTestRunFinalizationEventsHandlerTests | ||
{ | ||
private readonly Mock<ICommunicationManager> mockCommunicationManager; | ||
private readonly IMultiTestRunFinalizationEventsHandler handler; | ||
|
||
public MultiTestRunFinalizationEventsHandlerTests() | ||
{ | ||
this.mockCommunicationManager = new Mock<ICommunicationManager>(); | ||
this.handler = new MultiTestRunFinalizationEventsHandler(mockCommunicationManager.Object); | ||
} | ||
|
||
[TestMethod] | ||
public void EventsHandlerHandleLogMessageShouldSendTestMessage() | ||
{ | ||
string message = "error message"; | ||
|
||
handler.HandleLogMessage(TestMessageLevel.Error, message); | ||
|
||
mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.TestMessage, It.Is<TestMessagePayload>(p => p.MessageLevel == TestMessageLevel.Error && p.Message == message))); | ||
} | ||
|
||
[TestMethod] | ||
public void EventsHandlerHandleMultiTestRunFinalizationCompleteShouldSendFinalizationCompleteMessage() | ||
{ | ||
var attachments = new[] { new AttachmentSet(new System.Uri("http://www.bing.com/"), "code coverage") }; | ||
|
||
handler.HandleMultiTestRunFinalizationComplete(attachments); | ||
|
||
mockCommunicationManager.Verify(cm => cm.SendMessage(MessageType.MultiTestRunFinalizationComplete, It.Is<MultiTestRunFinalizationCompletePayload>(p => p.Attachments == attachments))); | ||
} | ||
|
||
[TestMethod] | ||
public void EventsHandlerHandleRawMessageShouldDoNothing() | ||
{ | ||
handler.HandleRawMessage("any"); | ||
|
||
mockCommunicationManager.Verify(cm => cm.SendMessage(It.IsAny<string>()), Times.Never); | ||
mockCommunicationManager.Verify(cm => cm.SendMessage(It.IsAny<string>(), It.IsAny<object>()), Times.Never); | ||
} | ||
} | ||
} |