-
Notifications
You must be signed in to change notification settings - Fork 325
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
7 changed files
with
388 additions
and
2 deletions.
There are no files selected for viewing
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
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
86 changes: 86 additions & 0 deletions
86
...ceptanceTests/TranslationLayerTests/EventHandler/MultiTestRunsFinalizationEventHandler.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,86 @@ | ||
// 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.AcceptanceTests.TranslationLayerTests | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Microsoft.VisualStudio.TestPlatform.ObjectModel; | ||
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; | ||
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; | ||
|
||
/// <inheritdoc /> | ||
public class MultiTestRunsFinalizationEventHandler : IMultiTestRunsFinalizationEventsHandler | ||
{ | ||
/// <summary> | ||
/// Gets the attachments. | ||
/// </summary> | ||
public List<AttachmentSet> Attachments { get; private set; } | ||
|
||
/// <summary> | ||
/// Gets the metrics. | ||
/// </summary> | ||
public IDictionary<string, object> Metrics { get; private set; } | ||
|
||
/// <summary> | ||
/// Gets the log message. | ||
/// </summary> | ||
public string LogMessage { get; private set; } | ||
|
||
public List<string> Errors { get; set; } | ||
|
||
/// <summary> | ||
/// Gets the test message level. | ||
/// </summary> | ||
public TestMessageLevel TestMessageLevel { get; private set; } | ||
|
||
public MultiTestRunsFinalizationEventHandler() | ||
{ | ||
this.Errors = new List<string>(); | ||
this.Attachments = new List<AttachmentSet>(); | ||
} | ||
|
||
public void EnsureSuccess() | ||
{ | ||
if (this.Errors.Any()) | ||
{ | ||
throw new InvalidOperationException($"Test run reported errors:{Environment.NewLine}{string.Join(Environment.NewLine + Environment.NewLine, this.Errors)}"); | ||
} | ||
} | ||
|
||
public void HandleLogMessage(TestMessageLevel level, string message) | ||
{ | ||
this.LogMessage = message; | ||
this.TestMessageLevel = level; | ||
if (level == TestMessageLevel.Error) { | ||
this.Errors.Add(message); | ||
} | ||
} | ||
|
||
public void HandleRawMessage(string rawMessage) | ||
{ | ||
// No op | ||
} | ||
|
||
public int LaunchProcessWithDebuggerAttached(TestProcessStartInfo testProcessStartInfo) | ||
{ | ||
// No op | ||
return -1; | ||
} | ||
|
||
public bool AttachDebuggerToProcess(int pid) | ||
{ | ||
// No op | ||
return true; | ||
} | ||
|
||
public void HandleMultiTestRunsFinalizationComplete(ICollection<AttachmentSet> attachments) | ||
{ | ||
if(attachments != null) | ||
{ | ||
this.Attachments.AddRange(attachments); | ||
} | ||
} | ||
} | ||
} |
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
Oops, something went wrong.