forked from microsoft/vstest
/
TestCaseTests.cs
193 lines (148 loc) · 6.2 KB
/
TestCaseTests.cs
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Microsoft.TestPlatform.ObjectModel.UnitTests;
[TestClass]
public class TestCaseTests
{
private readonly TestCase _testCase;
public TestCaseTests()
{
_testCase = new TestCase("sampleTestClass.sampleTestCase", new Uri("executor://sampleTestExecutor"), "sampleTest.dll");
}
[TestMethod]
public void TestCaseIdIfNotSetExplicitlyShouldReturnGuidBasedOnSourceAndName()
{
Assert.AreEqual("28e7a7ed-8fb9-05b7-5e90-4a8c52f32b5b", _testCase.Id.ToString());
}
[TestMethod]
public void TestCaseIdIfNotSetExplicitlyShouldReturnGuidBasedOnSourceAndNameIfNameIsChanged()
{
_testCase.FullyQualifiedName = "sampleTestClass1.sampleTestCase1";
Assert.AreEqual("6f86dd1c-7130-a1ae-8e7f-02e7de898a43", _testCase.Id.ToString());
}
[TestMethod]
public void TestCaseIdIfNotSetExplicitlyShouldReturnGuidBasedOnSourceAndNameIfSourceIsChanged()
{
_testCase.Source = "sampleTest1.dll";
Assert.AreEqual("22843fee-70ea-4cf4-37cd-5061b4c47a8a", _testCase.Id.ToString());
}
[TestMethod]
public void TestCaseIdShouldReturnIdSetExplicitlyEvenIfNameOrSourceInfoChanges()
{
var testGuid = new Guid("{8167845C-9CDB-476F-9F2B-1B1C1FE01B7D}");
_testCase.Id = testGuid;
_testCase.FullyQualifiedName = "sampleTestClass1.sampleTestCase1";
_testCase.Source = "sampleTest1.dll";
Assert.AreEqual(testGuid, _testCase.Id);
}
[TestMethod]
public void TestCaseLocalExtensionDataIsPubliclySettableGettableProperty()
{
var dummyData = "foo";
_testCase.LocalExtensionData = dummyData;
Assert.AreEqual("foo", _testCase.LocalExtensionData);
}
#region GetSetPropertyValue Tests
[TestMethod]
public void TestCaseGetPropertyValueForCodeFilePathShouldReturnCorrectValue()
{
var testCodeFilePath = "C:\\temp\foo.cs";
_testCase.CodeFilePath = testCodeFilePath;
Assert.AreEqual(testCodeFilePath, _testCase.GetPropertyValue(TestCaseProperties.CodeFilePath));
}
[TestMethod]
public void TestCaseGetPropertyValueForDisplayNameShouldReturnCorrectValue()
{
var testDisplayName = "testCaseDisplayName";
_testCase.DisplayName = testDisplayName;
Assert.AreEqual(testDisplayName, _testCase.GetPropertyValue(TestCaseProperties.DisplayName));
}
[TestMethod]
public void TestCaseGetPropertyValueForExecutorUriShouldReturnCorrectValue()
{
var testExecutorUri = new Uri("http://foo");
_testCase.ExecutorUri = testExecutorUri;
Assert.AreEqual(testExecutorUri, _testCase.GetPropertyValue(TestCaseProperties.ExecutorUri));
}
[TestMethod]
public void TestCaseGetPropertyValueForFullyQualifiedNameShouldReturnCorrectValue()
{
var testFullyQualifiedName = "fullyQualifiedName.Test1";
_testCase.FullyQualifiedName = testFullyQualifiedName;
Assert.AreEqual(testFullyQualifiedName, _testCase.GetPropertyValue(TestCaseProperties.FullyQualifiedName));
}
[TestMethod]
public void TestCaseGetPropertyValueForIdShouldReturnCorrectValue()
{
var testId = new Guid("{7845816C-9CDB-37DA-9ADF-1B1C1FE01B7D}");
_testCase.Id = testId;
Assert.AreEqual(testId, _testCase.GetPropertyValue(TestCaseProperties.Id));
}
[TestMethod]
public void TestCaseGetPropertyValueForLineNumberShouldReturnCorrectValue()
{
var testLineNumber = 34;
_testCase.LineNumber = testLineNumber;
Assert.AreEqual(testLineNumber, _testCase.GetPropertyValue(TestCaseProperties.LineNumber));
}
[TestMethod]
public void TestCaseGetPropertyValueForSourceShouldReturnCorrectValue()
{
var testSource = "C://temp/foobar.dll";
_testCase.Source = testSource;
Assert.AreEqual(testSource, _testCase.GetPropertyValue(TestCaseProperties.Source));
}
[TestMethod]
public void TestCaseSetPropertyValueForCodeFilePathShouldSetValue()
{
var testCodeFilePath = "C:\\temp\foo.cs";
_testCase.SetPropertyValue(TestCaseProperties.CodeFilePath, testCodeFilePath);
Assert.AreEqual(testCodeFilePath, _testCase.CodeFilePath);
}
[TestMethod]
public void TestCaseSetPropertyValueForDisplayNameShouldSetValue()
{
var testDisplayName = "testCaseDisplayName";
_testCase.SetPropertyValue(TestCaseProperties.DisplayName, testDisplayName);
Assert.AreEqual(testDisplayName, _testCase.DisplayName);
}
[TestMethod]
public void TestCaseSetPropertyValueForExecutorUriShouldSetValue()
{
var testExecutorUri = new Uri("http://foo");
_testCase.SetPropertyValue(TestCaseProperties.ExecutorUri, testExecutorUri);
Assert.AreEqual(testExecutorUri, _testCase.ExecutorUri);
}
[TestMethod]
public void TestCaseSetPropertyValueForFullyQualifiedNameShouldSetValue()
{
var testFullyQualifiedName = "fullyQualifiedName.Test1";
_testCase.SetPropertyValue(TestCaseProperties.FullyQualifiedName, testFullyQualifiedName);
Assert.AreEqual(testFullyQualifiedName, _testCase.FullyQualifiedName);
}
[TestMethod]
public void TestCaseSetPropertyValueForIdShouldSetValue()
{
var testId = new Guid("{7845816C-9CDB-37DA-9ADF-1B1C1FE01B7D}");
_testCase.SetPropertyValue(TestCaseProperties.Id, testId);
Assert.AreEqual(testId, _testCase.Id);
}
[TestMethod]
public void TestCaseSetPropertyValueForLineNumberShouldSetValue()
{
var testLineNumber = 34;
_testCase.SetPropertyValue(TestCaseProperties.LineNumber, testLineNumber);
Assert.AreEqual(testLineNumber, _testCase.LineNumber);
}
[TestMethod]
public void TestCaseSetPropertyValueForSourceShouldSetValue()
{
var testSource = "C://temp/foobar.dll";
_testCase.SetPropertyValue(TestCaseProperties.Source, testSource);
Assert.AreEqual(testSource, _testCase.Source);
}
#endregion
}