1
1
using System . Collections . Generic ;
2
2
using System . Linq ;
3
+ using System . Threading ;
3
4
using System . Windows . Media ;
4
5
using Moq ;
5
6
using NUnit . Framework ;
8
9
9
10
namespace RubberduckTests . UnitTesting
10
11
{
11
- [ TestFixture ]
12
+ [ NonParallelizable ]
13
+ [ TestFixture , Apartment ( ApartmentState . STA ) ]
12
14
public class TestExplorerModelTests
13
15
{
14
16
[ Test ]
@@ -45,13 +47,12 @@ public void ExecutedCount_MatchesNumberOfTestsRun(int testCount)
45
47
46
48
private const int DummyTestDuration = 10 ;
47
49
48
- // See comment in MockedTestEngine.SetupAssertCompleted re. commented code.
49
50
private static readonly Dictionary < TestOutcome , ( TestOutcome Outcome , string Output , long Duration ) > DummyOutcomes = new Dictionary < TestOutcome , ( TestOutcome , string , long ) >
50
51
{
51
52
{ TestOutcome . Succeeded , ( TestOutcome . Succeeded , "" , DummyTestDuration ) } ,
52
53
{ TestOutcome . Inconclusive , ( TestOutcome . Inconclusive , "" , DummyTestDuration ) } ,
53
54
{ TestOutcome . Failed , ( TestOutcome . Failed , "" , DummyTestDuration ) } ,
54
- // { TestOutcome.SpectacularFail, (TestOutcome.SpectacularFail, "", DummyTestDuration) },
55
+ { TestOutcome . SpectacularFail , ( TestOutcome . SpectacularFail , "" , DummyTestDuration ) } ,
55
56
{ TestOutcome . Ignored , ( TestOutcome . Ignored , "" , DummyTestDuration ) }
56
57
} ;
57
58
@@ -63,8 +64,7 @@ public void ExecutedCount_MatchesNumberOfTestsRun(int testCount)
63
64
[ TestCase ( new object [ ] { TestOutcome . Failed , TestOutcome . Failed , TestOutcome . Failed } ) ]
64
65
[ TestCase ( new object [ ] { TestOutcome . Succeeded , TestOutcome . Ignored } ) ]
65
66
[ TestCase ( new object [ ] { TestOutcome . Ignored , TestOutcome . Ignored , TestOutcome . Ignored } ) ]
66
- // See comment in MockedTestEngine.SetupAssertCompleted re. commented code.
67
- //[TestCase(new object[] { TestOutcome.Ignored, TestOutcome.SpectacularFail })]
67
+ [ TestCase ( new object [ ] { TestOutcome . Ignored , TestOutcome . SpectacularFail } ) ]
68
68
[ Category ( "Unit Testing" ) ]
69
69
public void LastTestSucceededCount_CountIsCorrect ( params TestOutcome [ ] tests )
70
70
{
@@ -74,6 +74,7 @@ public void LastTestSucceededCount_CountIsCorrect(params TestOutcome[] tests)
74
74
{
75
75
model . Engine . ParserState . OnParseRequested ( model ) ;
76
76
model . Model . ExecuteTests ( model . Model . Tests ) ;
77
+ Thread . SpinWait ( 25 ) ;
77
78
78
79
var expected = tests . Count ( outcome => outcome == TestOutcome . Succeeded ) ;
79
80
Assert . AreEqual ( expected , model . Model . LastTestSucceededCount ) ;
@@ -88,8 +89,7 @@ public void LastTestSucceededCount_CountIsCorrect(params TestOutcome[] tests)
88
89
[ TestCase ( new object [ ] { TestOutcome . Failed , TestOutcome . Failed , TestOutcome . Failed } ) ]
89
90
[ TestCase ( new object [ ] { TestOutcome . Succeeded , TestOutcome . Ignored } ) ]
90
91
[ TestCase ( new object [ ] { TestOutcome . Ignored , TestOutcome . Ignored , TestOutcome . Ignored } ) ]
91
- // See comment in MockedTestEngine.SetupAssertCompleted re. commented code.
92
- //[TestCase(new object[] { TestOutcome.Ignored, TestOutcome.SpectacularFail })]
92
+ [ TestCase ( new object [ ] { TestOutcome . Ignored , TestOutcome . SpectacularFail } ) ]
93
93
[ Category ( "Unit Testing" ) ]
94
94
public void LastTestIgnoredCount_CountIsCorrect ( params TestOutcome [ ] tests )
95
95
{
@@ -99,6 +99,7 @@ public void LastTestIgnoredCount_CountIsCorrect(params TestOutcome[] tests)
99
99
{
100
100
model . Engine . ParserState . OnParseRequested ( model ) ;
101
101
model . Model . ExecuteTests ( model . Model . Tests ) ;
102
+ Thread . SpinWait ( 25 ) ;
102
103
103
104
var expected = tests . Count ( outcome => outcome == TestOutcome . Ignored ) ;
104
105
Assert . AreEqual ( expected , model . Model . LastTestIgnoredCount ) ;
@@ -113,8 +114,7 @@ public void LastTestIgnoredCount_CountIsCorrect(params TestOutcome[] tests)
113
114
[ TestCase ( new object [ ] { TestOutcome . Failed , TestOutcome . Failed , TestOutcome . Failed } ) ]
114
115
[ TestCase ( new object [ ] { TestOutcome . Succeeded , TestOutcome . Ignored } ) ]
115
116
[ TestCase ( new object [ ] { TestOutcome . Ignored , TestOutcome . Ignored , TestOutcome . Ignored } ) ]
116
- // See comment in MockedTestEngine.SetupAssertCompleted re. commented code.
117
- //[TestCase(new object[] { TestOutcome.Ignored, TestOutcome.SpectacularFail })]
117
+ [ TestCase ( new object [ ] { TestOutcome . Ignored , TestOutcome . SpectacularFail } ) ]
118
118
[ Category ( "Unit Testing" ) ]
119
119
public void LastTestInconclusiveCount_CountIsCorrect ( params TestOutcome [ ] tests )
120
120
{
@@ -124,6 +124,7 @@ public void LastTestInconclusiveCount_CountIsCorrect(params TestOutcome[] tests)
124
124
{
125
125
model . Engine . ParserState . OnParseRequested ( model ) ;
126
126
model . Model . ExecuteTests ( model . Model . Tests ) ;
127
+ Thread . SpinWait ( 25 ) ;
127
128
128
129
var expected = tests . Count ( outcome => outcome == TestOutcome . Inconclusive ) ;
129
130
Assert . AreEqual ( expected , model . Model . LastTestInconclusiveCount ) ;
@@ -138,8 +139,7 @@ public void LastTestInconclusiveCount_CountIsCorrect(params TestOutcome[] tests)
138
139
[ TestCase ( new object [ ] { TestOutcome . Failed , TestOutcome . Failed , TestOutcome . Failed } ) ]
139
140
[ TestCase ( new object [ ] { TestOutcome . Succeeded , TestOutcome . Ignored } ) ]
140
141
[ TestCase ( new object [ ] { TestOutcome . Ignored , TestOutcome . Ignored , TestOutcome . Ignored } ) ]
141
- // See comment in MockedTestEngine.SetupAssertCompleted re. commented code.
142
- //[TestCase(new object[] { TestOutcome.Ignored, TestOutcome.SpectacularFail })]
142
+ [ TestCase ( new object [ ] { TestOutcome . Ignored , TestOutcome . SpectacularFail } ) ]
143
143
[ Category ( "Unit Testing" ) ]
144
144
public void LastTestFailedCount_CountIsCorrect ( params TestOutcome [ ] tests )
145
145
{
@@ -149,6 +149,7 @@ public void LastTestFailedCount_CountIsCorrect(params TestOutcome[] tests)
149
149
{
150
150
model . Engine . ParserState . OnParseRequested ( model ) ;
151
151
model . Model . ExecuteTests ( model . Model . Tests ) ;
152
+ Thread . SpinWait ( 25 ) ;
152
153
153
154
var expected = tests . Count ( outcome => outcome == TestOutcome . Failed ) ;
154
155
Assert . AreEqual ( expected , model . Model . LastTestFailedCount ) ;
@@ -162,9 +163,8 @@ public void LastTestFailedCount_CountIsCorrect(params TestOutcome[] tests)
162
163
[ TestCase ( new object [ ] { TestOutcome . Inconclusive , TestOutcome . Inconclusive , TestOutcome . Inconclusive } ) ]
163
164
[ TestCase ( new object [ ] { TestOutcome . Failed , TestOutcome . Failed , TestOutcome . Failed } ) ]
164
165
[ TestCase ( new object [ ] { TestOutcome . Succeeded , TestOutcome . Ignored } ) ]
165
- // See comment in MockedTestEngine.SetupAssertCompleted re. commented code.
166
- //[TestCase(new object[] { TestOutcome.SpectacularFail, TestOutcome.SpectacularFail, TestOutcome.Ignored })]
167
- //[TestCase(new object[] { TestOutcome.Ignored, TestOutcome.SpectacularFail })]
166
+ [ TestCase ( new object [ ] { TestOutcome . SpectacularFail , TestOutcome . SpectacularFail , TestOutcome . Ignored } ) ]
167
+ [ TestCase ( new object [ ] { TestOutcome . Ignored , TestOutcome . SpectacularFail } ) ]
168
168
[ Category ( "Unit Testing" ) ]
169
169
public void LastTestSpectacularFailCount_CountIsCorrect ( params TestOutcome [ ] tests )
170
170
{
@@ -174,6 +174,7 @@ public void LastTestSpectacularFailCount_CountIsCorrect(params TestOutcome[] tes
174
174
{
175
175
model . Engine . ParserState . OnParseRequested ( model ) ;
176
176
model . Model . ExecuteTests ( model . Model . Tests ) ;
177
+ Thread . SpinWait ( 25 ) ;
177
178
178
179
var expected = tests . Count ( outcome => outcome == TestOutcome . SpectacularFail ) ;
179
180
Assert . AreEqual ( expected , model . Model . LastTestSpectacularFailCount ) ;
@@ -201,7 +202,7 @@ public void CancelTestRun_RequestsCancellation()
201
202
{ "Gold" , Colors . Gold } ,
202
203
{ "Orange" , Colors . Orange } ,
203
204
{ "Red" , Colors . Red } ,
204
- // { "Black", Colors.Black }
205
+ { "Black" , Colors . Black }
205
206
} ;
206
207
207
208
[ Test ]
@@ -212,8 +213,7 @@ public void CancelTestRun_RequestsCancellation()
212
213
[ TestCase ( "Gold" , new [ ] { TestOutcome . Inconclusive , TestOutcome . Inconclusive , TestOutcome . Succeeded } ) ]
213
214
[ TestCase ( "Red" , new [ ] { TestOutcome . Failed , TestOutcome . Failed , TestOutcome . Failed } ) ]
214
215
[ TestCase ( "Orange" , new [ ] { TestOutcome . Succeeded , TestOutcome . Ignored } ) ]
215
- // See comment in MockedTestEngine.SetupAssertCompleted re. commented code.
216
- //[TestCase("Black", new [] { TestOutcome.Ignored, TestOutcome.SpectacularFail })]
216
+ [ TestCase ( "Black" , new [ ] { TestOutcome . Ignored , TestOutcome . SpectacularFail } ) ]
217
217
[ Category ( "Unit Testing" ) ]
218
218
public void ProgressBarColor_CorrectGivenTestResult ( params object [ ] args )
219
219
{
@@ -226,6 +226,7 @@ public void ProgressBarColor_CorrectGivenTestResult(params object[] args)
226
226
{
227
227
model . Engine . ParserState . OnParseRequested ( model ) ;
228
228
model . Model . ExecuteTests ( model . Model . Tests ) ;
229
+ Thread . SpinWait ( 25 ) ;
229
230
230
231
Assert . AreEqual ( ColorLookup [ expectedColor ] , model . Model . ProgressBarColor ) ;
231
232
}
0 commit comments