forked from microsoft/testfx
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUnitTestOutcomeExtensions.cs
More file actions
69 lines (57 loc) · 2.66 KB
/
Copy pathUnitTestOutcomeExtensions.cs
File metadata and controls
69 lines (57 loc) · 2.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// 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.VisualStudio.TestPlatform.MSTest.TestAdapter.Extensions
{
using Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.ObjectModel;
using UTF = Microsoft.VisualStudio.TestTools.UnitTesting;
public static class UnitTestOutcomeExtensions
{
/// <summary>
/// Converts the test framework's UnitTestOutcome object to adapter's UnitTestOutcome object.
/// </summary>
/// <param name="frameworkTestOutcome">The test framework's UnitTestOutcome object.</param>
/// <returns>The adapter's UnitTestOutcome object.</returns>
public static UnitTestOutcome ToUnitTestOutcome(this UTF.UnitTestOutcome frameworkTestOutcome)
{
UnitTestOutcome outcome = UnitTestOutcome.Passed;
switch (frameworkTestOutcome)
{
case UTF.UnitTestOutcome.Failed:
outcome = UnitTestOutcome.Failed;
break;
case UTF.UnitTestOutcome.Inconclusive:
outcome = UnitTestOutcome.Inconclusive;
break;
case UTF.UnitTestOutcome.InProgress:
outcome = UnitTestOutcome.InProgress;
break;
case UTF.UnitTestOutcome.Passed:
outcome = UnitTestOutcome.Passed;
break;
case UTF.UnitTestOutcome.Timeout:
outcome = UnitTestOutcome.Timeout;
break;
case UTF.UnitTestOutcome.NotRunnable:
outcome = UnitTestOutcome.NotRunnable;
break;
case UTF.UnitTestOutcome.Unknown:
default:
outcome = UnitTestOutcome.Error;
break;
}
return outcome;
}
/// <summary>
/// Returns more important outcome of two.
/// </summary>
/// <param name="outcome1"> First outcome that needs to be compared. </param>
/// <param name="outcome2"> Second outcome that needs to be compared. </param>
/// <returns> Outcome which has higher importance.</returns>
internal static UTF.UnitTestOutcome GetMoreImportantOutcome(this UTF.UnitTestOutcome outcome1, UTF.UnitTestOutcome outcome2)
{
var unitTestOutcome1 = outcome1.ToUnitTestOutcome();
var unitTestOutcome2 = outcome2.ToUnitTestOutcome();
return unitTestOutcome1 < unitTestOutcome2 ? outcome1 : outcome2;
}
}
}