1
1
using System . Collections . Generic ;
2
2
using NUnit . Framework ;
3
3
using System . Linq ;
4
- using System . Runtime . InteropServices ;
5
4
using Rubberduck . AddRemoveReferences ;
6
5
using Rubberduck . Parsing . Symbols ;
7
6
using Rubberduck . Navigation . CodeExplorer ;
@@ -21,7 +20,7 @@ public void Constructor_SetsDeclaration()
21
20
var declarations = CodeExplorerTestSetup . TestProjectOneDeclarations ;
22
21
var projectDeclaration = declarations . First ( declaration => declaration . DeclarationType == DeclarationType . Project ) ;
23
22
24
- var project = new CodeExplorerProjectViewModel ( projectDeclaration , ref declarations , null , null ) ;
23
+ var project = new CodeExplorerProjectViewModel ( projectDeclaration , ref declarations , null , null , CodeExplorerTestSetup . ProjectOneProvider ) ;
25
24
26
25
Assert . AreSame ( projectDeclaration , project . Declaration ) ;
27
26
}
@@ -33,7 +32,7 @@ public void Constructor_SetsName()
33
32
var declarations = CodeExplorerTestSetup . TestProjectOneDeclarations ;
34
33
var projectDeclaration = declarations . First ( declaration => declaration . DeclarationType == DeclarationType . Project ) ;
35
34
36
- var project = new CodeExplorerProjectViewModel ( projectDeclaration , ref declarations , null , null ) ;
35
+ var project = new CodeExplorerProjectViewModel ( projectDeclaration , ref declarations , null , null , CodeExplorerTestSetup . ProjectOneProvider ) ;
37
36
38
37
Assert . AreEqual ( CodeExplorerTestSetup . TestProjectOneName , project . Name ) ;
39
38
}
@@ -45,7 +44,7 @@ public void Constructor_NameWithSignatureIsSet()
45
44
var declarations = CodeExplorerTestSetup . TestProjectOneDeclarations ;
46
45
var projectDeclaration = declarations . First ( declaration => declaration . DeclarationType == DeclarationType . Project ) ;
47
46
48
- var project = new CodeExplorerProjectViewModel ( projectDeclaration , ref declarations , null , null ) ;
47
+ var project = new CodeExplorerProjectViewModel ( projectDeclaration , ref declarations , null , null , CodeExplorerTestSetup . ProjectOneProvider ) ;
49
48
50
49
Assert . IsFalse ( string . IsNullOrEmpty ( project . NameWithSignature ) ) ;
51
50
}
@@ -57,7 +56,7 @@ public void Constructor_PanelTitleIsSet()
57
56
var declarations = CodeExplorerTestSetup . TestProjectOneDeclarations ;
58
57
var projectDeclaration = declarations . First ( declaration => declaration . DeclarationType == DeclarationType . Project ) ;
59
58
60
- var project = new CodeExplorerProjectViewModel ( projectDeclaration , ref declarations , null , null ) ;
59
+ var project = new CodeExplorerProjectViewModel ( projectDeclaration , ref declarations , null , null , CodeExplorerTestSetup . ProjectOneProvider ) ;
61
60
62
61
Assert . IsFalse ( string . IsNullOrEmpty ( project . PanelTitle ) ) ;
63
62
}
@@ -69,7 +68,7 @@ public void Constructor_SetsIsExpandedTrue()
69
68
var declarations = CodeExplorerTestSetup . TestProjectOneDeclarations ;
70
69
var projectDeclaration = declarations . First ( declaration => declaration . DeclarationType == DeclarationType . Project ) ;
71
70
72
- var project = new CodeExplorerProjectViewModel ( projectDeclaration , ref declarations , null , null ) ;
71
+ var project = new CodeExplorerProjectViewModel ( projectDeclaration , ref declarations , null , null , CodeExplorerTestSetup . ProjectOneProvider ) ;
73
72
74
73
Assert . IsTrue ( project . IsExpanded ) ;
75
74
}
@@ -81,7 +80,7 @@ public void Constructor_ToolTipIsSet()
81
80
var declarations = CodeExplorerTestSetup . TestProjectOneDeclarations ;
82
81
var projectDeclaration = declarations . First ( declaration => declaration . DeclarationType == DeclarationType . Project ) ;
83
82
84
- var project = new CodeExplorerProjectViewModel ( projectDeclaration , ref declarations , null , null ) ;
83
+ var project = new CodeExplorerProjectViewModel ( projectDeclaration , ref declarations , null , null , CodeExplorerTestSetup . ProjectOneProvider ) ;
85
84
86
85
Assert . IsFalse ( string . IsNullOrEmpty ( project . ToolTip ) ) ;
87
86
}
@@ -99,7 +98,7 @@ public void SortComparerIsNodeType(CodeExplorerSortOrder order)
99
98
var declarations = CodeExplorerTestSetup . TestProjectOneDeclarations ;
100
99
var projectDeclaration = declarations . First ( declaration => declaration . DeclarationType == DeclarationType . Project ) ;
101
100
102
- var project = new CodeExplorerProjectViewModel ( projectDeclaration , ref declarations , null , null )
101
+ var project = new CodeExplorerProjectViewModel ( projectDeclaration , ref declarations , null , null , CodeExplorerTestSetup . ProjectOneProvider )
103
102
{
104
103
SortOrder = order
105
104
} ;
@@ -117,7 +116,7 @@ public void IsNotFiltered(string filter)
117
116
var declarations = CodeExplorerTestSetup . TestProjectOneDeclarations ;
118
117
var projectDeclaration = declarations . First ( declaration => declaration . DeclarationType == DeclarationType . Project ) ;
119
118
120
- var project = new CodeExplorerProjectViewModel ( projectDeclaration , ref declarations , null , null )
119
+ var project = new CodeExplorerProjectViewModel ( projectDeclaration , ref declarations , null , null , CodeExplorerTestSetup . ProjectOneProvider )
121
120
{
122
121
Filter = filter
123
122
} ;
@@ -173,7 +172,7 @@ public void Constructor_CreatesDefaultProjectFolder()
173
172
var declarations = CodeExplorerTestSetup . TestProjectOneDeclarations ;
174
173
var projectDeclaration = declarations . First ( declaration => declaration . DeclarationType == DeclarationType . Project ) ;
175
174
176
- var project = new CodeExplorerProjectViewModel ( projectDeclaration , ref declarations , null , null ) ;
175
+ var project = new CodeExplorerProjectViewModel ( projectDeclaration , ref declarations , null , null , CodeExplorerTestSetup . ProjectOneProvider ) ;
177
176
var folder = project . Children . OfType < CodeExplorerCustomFolderViewModel > ( ) . Single ( ) ;
178
177
179
178
Assert . AreEqual ( projectDeclaration . IdentifierName , folder . Name ) ;
@@ -187,7 +186,7 @@ public void Constructor_ClearsDeclarationList()
187
186
var projectDeclaration = declarations . First ( declaration => declaration . DeclarationType == DeclarationType . Project ) ;
188
187
189
188
// ReSharper disable once UnusedVariable
190
- var project = new CodeExplorerProjectViewModel ( projectDeclaration , ref declarations , null , null ) ;
189
+ var project = new CodeExplorerProjectViewModel ( projectDeclaration , ref declarations , null , null , CodeExplorerTestSetup . ProjectOneProvider ) ;
191
190
192
191
Assert . AreEqual ( 0 , declarations . Count ) ;
193
192
}
@@ -200,7 +199,7 @@ public void Synchronize_UsesDefaultProjectFolder_NoChanges()
200
199
var projectDeclaration = declarations . First ( declaration => declaration . DeclarationType == DeclarationType . Project ) ;
201
200
var updates = declarations . ToList ( ) ;
202
201
203
- var project = new CodeExplorerProjectViewModel ( projectDeclaration , ref declarations , null , null ) ;
202
+ var project = new CodeExplorerProjectViewModel ( projectDeclaration , ref declarations , null , null , CodeExplorerTestSetup . ProjectOneProvider ) ;
204
203
205
204
project . Synchronize ( ref updates ) ;
206
205
@@ -216,7 +215,7 @@ public void Synchronize_ClearsPassedDeclarationList_NoChanges()
216
215
var declarations = CodeExplorerTestSetup . TestProjectOneDeclarations ;
217
216
var projectDeclaration = declarations . First ( declaration => declaration . DeclarationType == DeclarationType . Project ) ;
218
217
219
- var project = new CodeExplorerProjectViewModel ( projectDeclaration , ref declarations , null , null ) ;
218
+ var project = new CodeExplorerProjectViewModel ( projectDeclaration , ref declarations , null , null , CodeExplorerTestSetup . ProjectOneProvider ) ;
220
219
var updates = CodeExplorerTestSetup . TestProjectOneDeclarations ;
221
220
project . Synchronize ( ref updates ) ;
222
221
@@ -230,7 +229,7 @@ public void Synchronize_DoesNotAlterDeclarationList_DifferentProject()
230
229
var declarations = CodeExplorerTestSetup . TestProjectOneDeclarations ;
231
230
var projectDeclaration = declarations . First ( declaration => declaration . DeclarationType == DeclarationType . Project ) ;
232
231
233
- var project = new CodeExplorerProjectViewModel ( projectDeclaration , ref declarations , null , null ) ;
232
+ var project = new CodeExplorerProjectViewModel ( projectDeclaration , ref declarations , null , null , CodeExplorerTestSetup . ProjectOneProvider ) ;
234
233
var updates = CodeExplorerTestSetup . TestProjectTwoDeclarations ;
235
234
project . Synchronize ( ref updates ) ;
236
235
@@ -252,7 +251,7 @@ public void Constructor_PlacesAllTrackedDeclarations()
252
251
var projectDeclaration = declarations . First ( declaration => declaration . DeclarationType == DeclarationType . Project ) ;
253
252
var results = declarations . ToList ( ) ;
254
253
255
- var project = new CodeExplorerProjectViewModel ( projectDeclaration , ref declarations , null , null ) ;
254
+ var project = new CodeExplorerProjectViewModel ( projectDeclaration , ref declarations , null , null , CodeExplorerTestSetup . ProjectOneProvider ) ;
256
255
257
256
var expected =
258
257
CodeExplorerProjectViewModel . ExtractTrackedDeclarationsForProject ( projectDeclaration , ref results )
@@ -273,7 +272,7 @@ public void Synchronize_PlacesAllTrackedDeclarations_NoChanges()
273
272
var declarations = CodeExplorerTestSetup . TestProjectOneDeclarations ;
274
273
var projectDeclaration = declarations . First ( declaration => declaration . DeclarationType == DeclarationType . Project ) ;
275
274
276
- var project = new CodeExplorerProjectViewModel ( projectDeclaration , ref declarations , null , null ) ;
275
+ var project = new CodeExplorerProjectViewModel ( projectDeclaration , ref declarations , null , null , CodeExplorerTestSetup . ProjectOneProvider ) ;
277
276
var updates = CodeExplorerTestSetup . TestProjectOneDeclarations ;
278
277
var results = updates . ToList ( ) ;
279
278
@@ -302,7 +301,7 @@ public void Synchronize_PlacesAllTrackedDeclarations_AddedComponent(string compo
302
301
var declarations = CodeExplorerTestSetup . TestProjectOneDeclarations
303
302
. TestProjectWithComponentDeclarations ( new [ ] { component } , out var projectDeclaration ) ;
304
303
305
- var project = new CodeExplorerProjectViewModel ( projectDeclaration , ref declarations , null , null ) ;
304
+ var project = new CodeExplorerProjectViewModel ( projectDeclaration , ref declarations , null , null , CodeExplorerTestSetup . ProjectOneProvider ) ;
306
305
307
306
var updates = CodeExplorerTestSetup . TestProjectOneDeclarations
308
307
. TestProjectWithComponentDeclarations ( new [ ] { component , added } , out _ ) . ToList ( ) ;
@@ -335,7 +334,7 @@ public void Synchronize_AddedComponent_SingleProjectFolderExists(string componen
335
334
var declarations = CodeExplorerTestSetup . TestProjectOneDeclarations
336
335
. TestProjectWithComponentDeclarations ( new [ ] { component } , out var projectDeclaration ) ;
337
336
338
- var project = new CodeExplorerProjectViewModel ( projectDeclaration , ref declarations , null , null ) ;
337
+ var project = new CodeExplorerProjectViewModel ( projectDeclaration , ref declarations , null , null , CodeExplorerTestSetup . ProjectOneProvider ) ;
339
338
340
339
var updates = CodeExplorerTestSetup . TestProjectOneDeclarations
341
340
. TestProjectWithComponentDeclarations ( new [ ] { component , added } , out _ ) ;
@@ -359,7 +358,7 @@ public void Synchronize_RemovesComponent(string removed)
359
358
var declarations = CodeExplorerTestSetup . TestProjectOneDeclarations ;
360
359
var projectDeclaration = declarations . First ( declaration => declaration . DeclarationType == DeclarationType . Project ) ;
361
360
362
- var project = new CodeExplorerProjectViewModel ( projectDeclaration , ref declarations , null , null ) ;
361
+ var project = new CodeExplorerProjectViewModel ( projectDeclaration , ref declarations , null , null , CodeExplorerTestSetup . ProjectOneProvider ) ;
363
362
364
363
var updates = CodeExplorerTestSetup . TestProjectOneDeclarations . TestProjectWithComponentRemoved ( removed ) ;
365
364
var expected = updates . Select ( declaration => declaration . QualifiedName . ToString ( ) )
@@ -382,7 +381,7 @@ public void Synchronize_SetsDeclarationNull_NoDeclarationsForProject()
382
381
var declarations = CodeExplorerTestSetup . TestProjectOneDeclarations ;
383
382
var projectDeclaration = declarations . First ( declaration => declaration . DeclarationType == DeclarationType . Project ) ;
384
383
385
- var project = new CodeExplorerProjectViewModel ( projectDeclaration , ref declarations , null , null ) ;
384
+ var project = new CodeExplorerProjectViewModel ( projectDeclaration , ref declarations , null , null , CodeExplorerTestSetup . ProjectOneProvider ) ;
386
385
if ( project . Declaration is null )
387
386
{
388
387
Assert . Inconclusive ( "Project declaration is null. Fix test setup and see why no other tests failed." ) ;
@@ -401,7 +400,7 @@ public void Synchronize_SetsDeclarationNull_DeclarationsForDifferentProject()
401
400
var declarations = CodeExplorerTestSetup . TestProjectOneDeclarations ;
402
401
var projectDeclaration = declarations . First ( declaration => declaration . DeclarationType == DeclarationType . Project ) ;
403
402
404
- var project = new CodeExplorerProjectViewModel ( projectDeclaration , ref declarations , null , null ) ;
403
+ var project = new CodeExplorerProjectViewModel ( projectDeclaration , ref declarations , null , null , CodeExplorerTestSetup . ProjectOneProvider ) ;
405
404
if ( project . Declaration is null )
406
405
{
407
406
Assert . Inconclusive ( "Project declaration is null. Fix test setup and see why no other tests failed." ) ;
@@ -426,7 +425,7 @@ public void Constructor_CreatesReferenceFolders(bool libraries, bool projects)
426
425
{
427
426
var projectDeclaration = declarations . First ( declaration => declaration . DeclarationType == DeclarationType . Project ) ;
428
427
429
- var project = new CodeExplorerProjectViewModel ( projectDeclaration , ref declarations , null , null ) ;
428
+ var project = new CodeExplorerProjectViewModel ( projectDeclaration , ref declarations , state , null , state . ProjectsProvider ) ;
430
429
431
430
var libraryFolder = project . Children . OfType < CodeExplorerReferenceFolderViewModel > ( )
432
431
. SingleOrDefault ( folder => folder . ReferenceKind == ReferenceKind . TypeLibrary ) ;
@@ -454,7 +453,7 @@ public void Synchronize_ReferenceFolders_NoChanges(bool libraries, bool projects
454
453
455
454
var expected = GetReferencesFromProjectDeclaration ( projectDeclaration , state . ProjectsProvider ) . Select ( reference => reference . Name ) . ToList ( ) ;
456
455
457
- var project = new CodeExplorerProjectViewModel ( projectDeclaration , ref declarations , null , null ) ;
456
+ var project = new CodeExplorerProjectViewModel ( projectDeclaration , ref declarations , state , null , state . ProjectsProvider ) ;
458
457
project . Synchronize ( ref updates ) ;
459
458
460
459
var actual = GetReferencesFromProjectViewModel ( project ) . OrderBy ( reference => reference . Priority ) . Select ( reference => reference . Name ) ;
@@ -477,7 +476,7 @@ public void Synchronize_ReferenceFolderRemoved(bool libraries, bool projects)
477
476
var updates = declarations . ToList ( ) ;
478
477
var projectDeclaration = declarations . First ( declaration => declaration . DeclarationType == DeclarationType . Project ) ;
479
478
480
- var project = new CodeExplorerProjectViewModel ( projectDeclaration , ref declarations , null , null ) ;
479
+ var project = new CodeExplorerProjectViewModel ( projectDeclaration , ref declarations , state , null , state . ProjectsProvider ) ;
481
480
482
481
var references = state . ProjectsProvider . Project ( projectDeclaration . ProjectId ) . References ;
483
482
foreach ( var reference in references . ToList ( ) )
0 commit comments