2
2
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
3
4
4
using System ;
5
- using System . Collections . Generic ;
6
5
using System . Linq ;
7
6
8
7
using FluentAssertions ;
@@ -24,9 +23,134 @@ public void ValidateTestRunLifecycle_net462()
24
23
ValidateTestRunLifecycle ( "net462" ) ;
25
24
}
26
25
26
+ public void ValidateInheritanceBehavior ( )
27
+ {
28
+ InvokeVsTestForExecution (
29
+ new [ ] { "net462\\ " + Assembly } ,
30
+ testCaseFilter : "FullyQualifiedName~LifecycleInheritance" ,
31
+ targetFramework : "net462" ) ;
32
+
33
+ RunEventsHandler . PassedTests . Should ( ) . HaveCount ( 10 ) ;
34
+
35
+ var testMethod1 = RunEventsHandler . PassedTests . Single ( x => x . TestCase . FullyQualifiedName . EndsWith ( "TestClassDerived_EndOfClass.TestMethod" ) ) ;
36
+ testMethod1 . Messages [ 0 ] . Text . Should ( ) . Be (
37
+ """
38
+ Console: AssemblyInit was called
39
+ TestClassBaseEndOfClass: ClassInitialize
40
+ TestClassDerived_EndOfClass: TestMethod
41
+ TestClassBaseEndOfClass: ClassCleanup
42
+
43
+ """ ) ;
44
+
45
+ var testMethod2 = RunEventsHandler . PassedTests . Single ( x => x . TestCase . FullyQualifiedName . EndsWith ( "TestClassDerived_EndOfAssembly.TestMethod" ) ) ;
46
+ testMethod2 . Messages [ 0 ] . Text . Should ( ) . Be (
47
+ """
48
+ TestClassBaseEndOfAssembly: ClassInitialize
49
+ TestClassDerived_EndOfAssembly: TestMethod
50
+
51
+ """ ) ;
52
+
53
+ var testMethod3 = RunEventsHandler . PassedTests . Single ( x => x . TestCase . FullyQualifiedName . EndsWith ( "TestClassDerivedEndOfClass_EndOfClassEndOfClass.TestMethod" ) ) ;
54
+ testMethod3 . Messages [ 0 ] . Text . Should ( ) . Be (
55
+ """
56
+ TestClassBaseEndOfClass: ClassInitialize
57
+ TestClassIntermediateEndOfClassBaseEndOfClass: ClassInitialize
58
+ TestClassDerivedEndOfClass_EndOfClassEndOfClass: TestMethod
59
+ TestClassDerivedEndOfClass_EndOfClassEndOfClass: ClassCleanup
60
+ TestClassIntermediateEndOfClassBaseEndOfClass: ClassCleanup
61
+ TestClassBaseEndOfClass: ClassCleanup
62
+
63
+ """ ) ;
64
+
65
+ var testMethod4 = RunEventsHandler . PassedTests . Single ( x => x . TestCase . FullyQualifiedName . EndsWith ( "TestClassDerived_EndOfClassEndOfClass.TestMethod" ) ) ;
66
+ testMethod4 . Messages [ 0 ] . Text . Should ( ) . Be (
67
+ """
68
+ TestClassBaseEndOfClass: ClassInitialize
69
+ TestClassIntermediateEndOfClassBaseEndOfClass: ClassInitialize
70
+ TestClassDerived_EndOfClassEndOfClass: TestMethod
71
+ TestClassIntermediateEndOfClassBaseEndOfClass: ClassCleanup
72
+ TestClassBaseEndOfClass: ClassCleanup
73
+
74
+ """ ) ;
75
+
76
+ var testMethod5 = RunEventsHandler . PassedTests . Single ( x => x . TestCase . FullyQualifiedName . EndsWith ( "TestClassDerivedEndOfClass_EndOfClassEndOfAssembly.TestMethod" ) ) ;
77
+ testMethod5 . Messages [ 0 ] . Text . Should ( ) . Be (
78
+ """
79
+ TestClassBaseEndOfAssembly: ClassInitialize
80
+ TestClassIntermediateEndOfClassBaseEndOfAssembly: ClassInitialize
81
+ TestClassDerivedEndOfClass_EndOfClassEndOfAssembly: TestMethod
82
+ TestClassDerivedEndOfClass_EndOfClassEndOfAssembly: ClassCleanup
83
+ TestClassIntermediateEndOfClassBaseEndOfAssembly: ClassCleanup
84
+ TestClassBaseEndOfAssembly: ClassCleanup
85
+
86
+ """ ) ;
87
+
88
+ var testMethod6 = RunEventsHandler . PassedTests . Single ( x => x . TestCase . FullyQualifiedName . EndsWith ( "TestClassDerived_EndOfClassEndOfAssembly.TestMethod" ) ) ;
89
+ testMethod6 . Messages [ 0 ] . Text . Should ( ) . Be (
90
+ """
91
+ TestClassBaseEndOfAssembly: ClassInitialize
92
+ TestClassIntermediateEndOfClassBaseEndOfAssembly: ClassInitialize
93
+ TestClassDerived_EndOfClassEndOfAssembly: TestMethod
94
+ TestClassIntermediateEndOfClassBaseEndOfAssembly: ClassCleanup
95
+ TestClassBaseEndOfAssembly: ClassCleanup
96
+
97
+ """ ) ;
98
+
99
+ var testMethod7 = RunEventsHandler . PassedTests . Single ( x => x . TestCase . FullyQualifiedName . EndsWith ( "TestClassDerivedEndOfClass_EndOfAssemblyEndOfClass.TestMethod" ) ) ;
100
+ testMethod7 . Messages [ 0 ] . Text . Should ( ) . Be (
101
+ """
102
+ TestClassBaseEndOfClass: ClassInitialize
103
+ TestClassIntermediateEndOfAssemblyBaseEndOfClass: ClassInitialize
104
+ TestClassDerivedEndOfClass_EndOfAssemblyEndOfClass: TestMethod
105
+ TestClassDerivedEndOfClass_EndOfAssemblyEndOfClass: ClassCleanup
106
+ TestClassIntermediateEndOfAssemblyBaseEndOfClass: ClassCleanup
107
+ TestClassBaseEndOfClass: ClassCleanup
108
+
109
+ """ ) ;
110
+
111
+ var testMethod8 = RunEventsHandler . PassedTests . Single ( x => x . TestCase . FullyQualifiedName . EndsWith ( "TestClassDerived_EndOfAssemblyEndOfClass.TestMethod" ) ) ;
112
+ testMethod8 . Messages [ 0 ] . Text . Should ( ) . Be (
113
+ """
114
+ TestClassBaseEndOfClass: ClassInitialize
115
+ TestClassIntermediateEndOfAssemblyBaseEndOfClass: ClassInitialize
116
+ TestClassDerived_EndOfAssemblyEndOfClass: TestMethod
117
+ TestClassIntermediateEndOfAssemblyBaseEndOfClass: ClassCleanup
118
+ TestClassBaseEndOfClass: ClassCleanup
119
+
120
+ """ ) ;
121
+
122
+ var testMethod9 = RunEventsHandler . PassedTests . Single ( x => x . TestCase . FullyQualifiedName . EndsWith ( "TestClassDerivedEndOfClass_EndOfAssemblyEndOfAssembly.TestMethod" ) ) ;
123
+ testMethod9 . Messages [ 0 ] . Text . Should ( ) . Be (
124
+ """
125
+ TestClassBaseEndOfAssembly: ClassInitialize
126
+ TestClassIntermediateEndOfAssemblyBaseEndOfAssembly: ClassInitialize
127
+ TestClassDerivedEndOfClass_EndOfAssemblyEndOfAssembly: TestMethod
128
+ TestClassDerivedEndOfClass_EndOfAssemblyEndOfAssembly: ClassCleanup
129
+ TestClassIntermediateEndOfAssemblyBaseEndOfAssembly: ClassCleanup
130
+ TestClassBaseEndOfAssembly: ClassCleanup
131
+
132
+ """ ) ;
133
+
134
+ var testMethod10 = RunEventsHandler . PassedTests . Single ( x => x . TestCase . FullyQualifiedName . EndsWith ( "TestClassDerived_EndOfAssemblyEndOfAssembly.TestMethod" ) ) ;
135
+ testMethod10 . Messages [ 0 ] . Text . Should ( ) . Be (
136
+ """
137
+ TestClassBaseEndOfAssembly: ClassInitialize
138
+ TestClassIntermediateEndOfAssemblyBaseEndOfAssembly: ClassInitialize
139
+ TestClassDerived_EndOfAssemblyEndOfAssembly: TestMethod
140
+ TestClassIntermediateEndOfAssemblyBaseEndOfAssembly: ClassCleanup
141
+ TestClassBaseEndOfAssembly: ClassCleanup
142
+ TestClassBaseEndOfAssembly: ClassCleanup
143
+ Console: AssemblyCleanup was called
144
+
145
+ """ ) ;
146
+ }
147
+
27
148
private void ValidateTestRunLifecycle ( string targetFramework )
28
149
{
29
- InvokeVsTestForExecution ( new [ ] { targetFramework + "\\ " + Assembly } , targetFramework : targetFramework ) ;
150
+ InvokeVsTestForExecution (
151
+ new [ ] { targetFramework + "\\ " + Assembly } ,
152
+ testCaseFilter : "FullyQualifiedName~SuiteLifeCycleTestProject" ,
153
+ targetFramework : targetFramework ) ;
30
154
RunEventsHandler . PassedTests . Should ( ) . HaveCount ( 27 ) ; // The inherit class tests are called twice.
31
155
32
156
var caseClassCleanup = RunEventsHandler . PassedTests . Single ( x => x . TestCase . FullyQualifiedName . Contains ( "LifeCycleClassCleanup.TestMethod" ) ) ;
0 commit comments