-
Notifications
You must be signed in to change notification settings - Fork 220
Expand file tree
/
Copy pathMtpTestCaseTests.cs
More file actions
121 lines (99 loc) · 3.85 KB
/
MtpTestCaseTests.cs
File metadata and controls
121 lines (99 loc) · 3.85 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
using System.Text.Json;
using Shouldly;
using Stryker.TestRunner.MicrosoftTestPlatform.Models;
namespace Stryker.TestRunner.MicrosoftTestPlatform.UnitTest;
[TestClass]
public class MtpTestCaseTests
{
[TestMethod]
public void MtpTestCase_WithLocationProperties_PopulatesCodeFilePath()
{
var testNode = new TestNode("uid-1", "TestMethod1", "action", "discovered",
LocationFile: "/path/to/TestFile.cs",
LocationLineStart: 42);
var testCase = new MtpTestCase(testNode);
testCase.CodeFilePath.ShouldBe("/path/to/TestFile.cs");
testCase.LineNumber.ShouldBe(42);
}
[TestMethod]
public void MtpTestCase_WithLocationTypeAndMethod_BuildsFullyQualifiedName()
{
var testNode = new TestNode("uid-1", "TestMethod1", "action", "discovered",
LocationType: "MyNamespace.MyTestClass",
LocationMethod: "TestMethod1");
var testCase = new MtpTestCase(testNode);
testCase.FullyQualifiedName.ShouldBe("MyNamespace.MyTestClass.TestMethod1");
}
[TestMethod]
public void MtpTestCase_WithoutLocationProperties_UsesDefaults()
{
var testNode = new TestNode("uid-1", "TestMethod1", "action", "discovered");
var testCase = new MtpTestCase(testNode);
testCase.CodeFilePath.ShouldBe(string.Empty);
testCase.LineNumber.ShouldBe(0);
testCase.FullyQualifiedName.ShouldBe("uid-1");
}
[TestMethod]
public void MtpTestCase_WithoutLocationType_FallsBackToUid()
{
var testNode = new TestNode("uid-1", "TestMethod1", "action", "discovered",
LocationFile: "/path/to/TestFile.cs",
LocationLineStart: 10);
var testCase = new MtpTestCase(testNode);
testCase.FullyQualifiedName.ShouldBe("uid-1");
}
[TestMethod]
public void MtpTestCase_PreservesBasicProperties()
{
var testNode = new TestNode("uid-1", "TestMethod1", "action", "discovered");
var testCase = new MtpTestCase(testNode);
testCase.Id.ShouldBe("uid-1");
testCase.Name.ShouldBe("TestMethod1");
testCase.Uri.ShouldBe(new Uri("executor://MicrosoftTestPlatform"));
}
[TestMethod]
public void TestNode_DeserializesLocationPropertiesFromJson()
{
var json = """
{
"uid": "uid-1",
"display-name": "TestMethod1",
"node-type": "action",
"execution-state": "discovered",
"location.file": "/path/to/TestFile.cs",
"location.line-start": 42,
"location.line-end": 50,
"location.type": "MyNamespace.MyTestClass",
"location.method": "TestMethod1"
}
""";
var testNode = JsonSerializer.Deserialize<TestNode>(json);
testNode.ShouldNotBeNull();
testNode.Uid.ShouldBe("uid-1");
testNode.DisplayName.ShouldBe("TestMethod1");
testNode.LocationFile.ShouldBe("/path/to/TestFile.cs");
testNode.LocationLineStart.ShouldBe(42);
testNode.LocationLineEnd.ShouldBe(50);
testNode.LocationType.ShouldBe("MyNamespace.MyTestClass");
testNode.LocationMethod.ShouldBe("TestMethod1");
}
[TestMethod]
public void TestNode_DeserializesWithoutLocationPropertiesFromJson()
{
var json = """
{
"uid": "uid-1",
"display-name": "TestMethod1",
"node-type": "action",
"execution-state": "discovered"
}
""";
var testNode = JsonSerializer.Deserialize<TestNode>(json);
testNode.ShouldNotBeNull();
testNode.Uid.ShouldBe("uid-1");
testNode.LocationFile.ShouldBeNull();
testNode.LocationLineStart.ShouldBeNull();
testNode.LocationType.ShouldBeNull();
testNode.LocationMethod.ShouldBeNull();
}
}