@@ -49,7 +49,6 @@ public void CanBuildTreeForSingleItem()
49
49
children [ 0 ] . Target . Should ( ) . Be ( gitCommitTargets [ 0 ] ) ;
50
50
51
51
children [ 0 ] . Children . Should ( ) . BeEmpty ( ) ;
52
-
53
52
}
54
53
55
54
[ Test ]
@@ -86,6 +85,74 @@ public void CanBuildTreeForSingleItemWhenProjectNestedInRepo()
86
85
children [ 0 ] . Children . Should ( ) . BeEmpty ( ) ;
87
86
}
88
87
88
+ [ Test ]
89
+ public void CanBuildTreeForSingleItemInFolder ( )
90
+ {
91
+ InitializeEnvironment ( @"c:\Project" , @"c:\Project" ) ;
92
+
93
+ var newGitStatusEntries = new List < GitStatusEntry > ( ) {
94
+ gitObjectFactory . CreateGitStatusEntry ( @"folder\file1.txt" , GitFileStatus . Modified )
95
+ } ;
96
+ var gitStatusEntries = new List < GitStatusEntry > ( ) ;
97
+
98
+ var gitCommitTargets = new List < GitCommitTarget > ( ) ;
99
+ var foldedTreeEntries = new List < string > ( ) ;
100
+
101
+ Action < FileTreeNode > stateChangeCallback = node => { } ;
102
+
103
+ var treeRoot = TreeBuilder . BuildTreeRoot ( newGitStatusEntries , gitStatusEntries , gitCommitTargets ,
104
+ foldedTreeEntries , stateChangeCallback ) ;
105
+
106
+ var children = treeRoot . Children . ToArray ( ) ;
107
+ children . Length . Should ( ) . Be ( 1 ) ;
108
+
109
+ gitCommitTargets . Count . Should ( ) . Be ( 1 ) ;
110
+
111
+ children [ 0 ] . Label . Should ( ) . Be ( "file1.txt" ) ;
112
+ children [ 0 ] . Open . Should ( ) . BeTrue ( ) ;
113
+ children [ 0 ] . Path . Should ( ) . Be ( "file1.txt" ) ;
114
+ children [ 0 ] . RepositoryPath . Should ( ) . Be ( @"folder\file1.txt" ) ;
115
+ children [ 0 ] . State . Should ( ) . Be ( CommitState . None ) ;
116
+ children [ 0 ] . State . Should ( ) . Be ( CommitState . None ) ;
117
+ children [ 0 ] . Target . Should ( ) . Be ( gitCommitTargets [ 0 ] ) ;
118
+
119
+ children [ 0 ] . Children . Should ( ) . BeEmpty ( ) ;
120
+ }
121
+
122
+ [ Test ]
123
+ public void CanBuildTreeForSingleItemInFolderWhenProjectNestedInRepo ( )
124
+ {
125
+ InitializeEnvironment ( @"c:\Repo" , @"c:\Repo\Project" ) ;
126
+
127
+ var newGitStatusEntries = new List < GitStatusEntry > ( ) {
128
+ gitObjectFactory . CreateGitStatusEntry ( @"folder\file1.txt" , GitFileStatus . Modified )
129
+ } ;
130
+ var gitStatusEntries = new List < GitStatusEntry > ( ) ;
131
+
132
+ var gitCommitTargets = new List < GitCommitTarget > ( ) ;
133
+ var foldedTreeEntries = new List < string > ( ) ;
134
+
135
+ Action < FileTreeNode > stateChangeCallback = node => { } ;
136
+
137
+ var treeRoot = TreeBuilder . BuildTreeRoot ( newGitStatusEntries , gitStatusEntries , gitCommitTargets ,
138
+ foldedTreeEntries , stateChangeCallback ) ;
139
+
140
+ var children = treeRoot . Children . ToArray ( ) ;
141
+ children . Length . Should ( ) . Be ( 1 ) ;
142
+
143
+ gitCommitTargets . Count . Should ( ) . Be ( 1 ) ;
144
+
145
+ children [ 0 ] . Label . Should ( ) . Be ( "file1.txt" ) ;
146
+ children [ 0 ] . Open . Should ( ) . BeTrue ( ) ;
147
+ children [ 0 ] . Path . Should ( ) . Be ( "file1.txt" ) ;
148
+ children [ 0 ] . RepositoryPath . Should ( ) . Be ( @"Project\folder\file1.txt" ) ;
149
+ children [ 0 ] . State . Should ( ) . Be ( CommitState . None ) ;
150
+ children [ 0 ] . State . Should ( ) . Be ( CommitState . None ) ;
151
+ children [ 0 ] . Target . Should ( ) . Be ( gitCommitTargets [ 0 ] ) ;
152
+
153
+ children [ 0 ] . Children . Should ( ) . BeEmpty ( ) ;
154
+ }
155
+
89
156
[ Test ]
90
157
public void CanBuildTreeForMultipleSiblings ( )
91
158
{
@@ -183,7 +250,10 @@ public void CanBuildTreeForHierarchy()
183
250
184
251
var newGitStatusEntries = new List < GitStatusEntry > ( ) {
185
252
gitObjectFactory . CreateGitStatusEntry ( "file1.txt" , GitFileStatus . Modified ) ,
186
- gitObjectFactory . CreateGitStatusEntry ( @"folder\file2.txt" , GitFileStatus . Modified )
253
+ gitObjectFactory . CreateGitStatusEntry ( @"folder1\file2.txt" , GitFileStatus . Modified ) ,
254
+ gitObjectFactory . CreateGitStatusEntry ( @"folder1\file3.txt" , GitFileStatus . Modified ) ,
255
+ gitObjectFactory . CreateGitStatusEntry ( @"folder2\file4.txt" , GitFileStatus . Modified ) ,
256
+ gitObjectFactory . CreateGitStatusEntry ( @"folder2\file5.txt" , GitFileStatus . Modified )
187
257
} ;
188
258
var gitStatusEntries = new List < GitStatusEntry > ( ) ;
189
259
@@ -196,9 +266,9 @@ public void CanBuildTreeForHierarchy()
196
266
foldedTreeEntries , stateChangeCallback ) ;
197
267
198
268
var children = treeRoot . Children . ToArray ( ) ;
199
- children . Length . Should ( ) . Be ( 2 ) ;
269
+ children . Length . Should ( ) . Be ( 3 ) ;
200
270
201
- gitCommitTargets . Count . Should ( ) . Be ( 2 ) ;
271
+ gitCommitTargets . Count . Should ( ) . Be ( 5 ) ;
202
272
203
273
children [ 0 ] . Label . Should ( ) . Be ( "file1.txt" ) ;
204
274
children [ 0 ] . Open . Should ( ) . BeTrue ( ) ;
@@ -210,26 +280,67 @@ public void CanBuildTreeForHierarchy()
210
280
211
281
children [ 0 ] . Children . Should ( ) . BeEmpty ( ) ;
212
282
213
- children [ 1 ] . Label . Should ( ) . Be ( "folder " ) ;
283
+ children [ 1 ] . Label . Should ( ) . Be ( "folder1 " ) ;
214
284
children [ 1 ] . Open . Should ( ) . BeTrue ( ) ;
215
- children [ 1 ] . Path . Should ( ) . Be ( "folder " ) ;
216
- children [ 1 ] . RepositoryPath . Should ( ) . Be ( "folder " ) ;
285
+ children [ 1 ] . Path . Should ( ) . Be ( "folder1 " ) ;
286
+ children [ 1 ] . RepositoryPath . Should ( ) . Be ( "folder1 " ) ;
217
287
children [ 1 ] . State . Should ( ) . Be ( CommitState . None ) ;
218
288
children [ 1 ] . State . Should ( ) . Be ( CommitState . None ) ;
219
289
children [ 1 ] . Target . Should ( ) . BeNull ( ) ;
220
290
221
- var folderChildren = children [ 1 ] . Children . ToArray ( ) ;
222
- folderChildren . Length . Should ( ) . Be ( 1 ) ;
223
-
224
- folderChildren [ 0 ] . Label . Should ( ) . Be ( "file2.txt" ) ;
225
- folderChildren [ 0 ] . Open . Should ( ) . BeTrue ( ) ;
226
- folderChildren [ 0 ] . Path . Should ( ) . Be ( @"folder\file2.txt" ) ;
227
- folderChildren [ 0 ] . RepositoryPath . Should ( ) . Be ( @"folder\file2.txt" ) ;
228
- folderChildren [ 0 ] . State . Should ( ) . Be ( CommitState . None ) ;
229
- folderChildren [ 0 ] . State . Should ( ) . Be ( CommitState . None ) ;
230
- folderChildren [ 0 ] . Target . Should ( ) . Be ( gitCommitTargets [ 1 ] ) ;
231
-
232
- folderChildren [ 0 ] . Children . Should ( ) . BeEmpty ( ) ;
291
+ children [ 2 ] . Label . Should ( ) . Be ( "folder2" ) ;
292
+ children [ 2 ] . Open . Should ( ) . BeTrue ( ) ;
293
+ children [ 2 ] . Path . Should ( ) . Be ( "folder2" ) ;
294
+ children [ 2 ] . RepositoryPath . Should ( ) . Be ( "folder2" ) ;
295
+ children [ 2 ] . State . Should ( ) . Be ( CommitState . None ) ;
296
+ children [ 2 ] . State . Should ( ) . Be ( CommitState . None ) ;
297
+ children [ 2 ] . Target . Should ( ) . BeNull ( ) ;
298
+
299
+ var folder1Children = children [ 1 ] . Children . ToArray ( ) ;
300
+ folder1Children . Length . Should ( ) . Be ( 2 ) ;
301
+
302
+ folder1Children [ 0 ] . Label . Should ( ) . Be ( "file2.txt" ) ;
303
+ folder1Children [ 0 ] . Open . Should ( ) . BeTrue ( ) ;
304
+ folder1Children [ 0 ] . Path . Should ( ) . Be ( @"folder1\file2.txt" ) ;
305
+ folder1Children [ 0 ] . RepositoryPath . Should ( ) . Be ( @"folder1\file2.txt" ) ;
306
+ folder1Children [ 0 ] . State . Should ( ) . Be ( CommitState . None ) ;
307
+ folder1Children [ 0 ] . State . Should ( ) . Be ( CommitState . None ) ;
308
+ folder1Children [ 0 ] . Target . Should ( ) . Be ( gitCommitTargets [ 1 ] ) ;
309
+
310
+ folder1Children [ 0 ] . Children . Should ( ) . BeEmpty ( ) ;
311
+
312
+ folder1Children [ 1 ] . Label . Should ( ) . Be ( "file3.txt" ) ;
313
+ folder1Children [ 1 ] . Open . Should ( ) . BeTrue ( ) ;
314
+ folder1Children [ 1 ] . Path . Should ( ) . Be ( @"folder1\file3.txt" ) ;
315
+ folder1Children [ 1 ] . RepositoryPath . Should ( ) . Be ( @"folder1\file3.txt" ) ;
316
+ folder1Children [ 1 ] . State . Should ( ) . Be ( CommitState . None ) ;
317
+ folder1Children [ 1 ] . State . Should ( ) . Be ( CommitState . None ) ;
318
+ folder1Children [ 1 ] . Target . Should ( ) . Be ( gitCommitTargets [ 2 ] ) ;
319
+
320
+ folder1Children [ 1 ] . Children . Should ( ) . BeEmpty ( ) ;
321
+
322
+ var folder2Children = children [ 2 ] . Children . ToArray ( ) ;
323
+ folder2Children . Length . Should ( ) . Be ( 2 ) ;
324
+
325
+ folder2Children [ 0 ] . Label . Should ( ) . Be ( "file4.txt" ) ;
326
+ folder2Children [ 0 ] . Open . Should ( ) . BeTrue ( ) ;
327
+ folder2Children [ 0 ] . Path . Should ( ) . Be ( @"folder2\file4.txt" ) ;
328
+ folder2Children [ 0 ] . RepositoryPath . Should ( ) . Be ( @"folder2\file4.txt" ) ;
329
+ folder2Children [ 0 ] . State . Should ( ) . Be ( CommitState . None ) ;
330
+ folder2Children [ 0 ] . State . Should ( ) . Be ( CommitState . None ) ;
331
+ folder2Children [ 0 ] . Target . Should ( ) . Be ( gitCommitTargets [ 3 ] ) ;
332
+
333
+ folder2Children [ 0 ] . Children . Should ( ) . BeEmpty ( ) ;
334
+
335
+ folder2Children [ 1 ] . Label . Should ( ) . Be ( "file5.txt" ) ;
336
+ folder2Children [ 1 ] . Open . Should ( ) . BeTrue ( ) ;
337
+ folder2Children [ 1 ] . Path . Should ( ) . Be ( @"folder2\file5.txt" ) ;
338
+ folder2Children [ 1 ] . RepositoryPath . Should ( ) . Be ( @"folder2\file5.txt" ) ;
339
+ folder2Children [ 1 ] . State . Should ( ) . Be ( CommitState . None ) ;
340
+ folder2Children [ 1 ] . State . Should ( ) . Be ( CommitState . None ) ;
341
+ folder2Children [ 1 ] . Target . Should ( ) . Be ( gitCommitTargets [ 4 ] ) ;
342
+
343
+ folder2Children [ 1 ] . Children . Should ( ) . BeEmpty ( ) ;
233
344
}
234
345
235
346
[ Test ]
@@ -288,6 +399,55 @@ public void CanBuildTreeForHierarchyWhenProjectNestedInRepo()
288
399
folderChildren [ 0 ] . Children . Should ( ) . BeEmpty ( ) ;
289
400
}
290
401
402
+ [ Test ]
403
+ public void CanBuildTreeForItemAndMetafile ( )
404
+ {
405
+ InitializeEnvironment ( @"c:\Project" , @"c:\Project" ) ;
406
+
407
+ var newGitStatusEntries = new List < GitStatusEntry > ( ) {
408
+ gitObjectFactory . CreateGitStatusEntry ( "file1.txt" , GitFileStatus . Modified ) ,
409
+ gitObjectFactory . CreateGitStatusEntry ( "file1.txt.meta" , GitFileStatus . Modified )
410
+ } ;
411
+ var gitStatusEntries = new List < GitStatusEntry > ( ) ;
412
+
413
+ var gitCommitTargets = new List < GitCommitTarget > ( ) ;
414
+ var foldedTreeEntries = new List < string > ( ) ;
415
+
416
+ Action < FileTreeNode > stateChangeCallback = node => { } ;
417
+
418
+ var treeRoot = TreeBuilder . BuildTreeRoot ( newGitStatusEntries , gitStatusEntries , gitCommitTargets ,
419
+ foldedTreeEntries , stateChangeCallback ) ;
420
+
421
+ var children = treeRoot . Children . ToArray ( ) ;
422
+ children . Length . Should ( ) . Be ( 1 ) ;
423
+
424
+ gitCommitTargets . Count . Should ( ) . Be ( 2 ) ;
425
+
426
+ children [ 0 ] . Label . Should ( ) . Be ( "file1.txt" ) ;
427
+ children [ 0 ] . Open . Should ( ) . BeTrue ( ) ;
428
+ children [ 0 ] . Path . Should ( ) . Be ( "file1.txt" ) ;
429
+ children [ 0 ] . RepositoryPath . Should ( ) . Be ( "file1.txt" ) ;
430
+ children [ 0 ] . State . Should ( ) . Be ( CommitState . None ) ;
431
+ children [ 0 ] . State . Should ( ) . Be ( CommitState . None ) ;
432
+ children [ 0 ] . Target . Should ( ) . Be ( gitCommitTargets [ 0 ] ) ;
433
+
434
+ var fileChildren = children [ 0 ] . Children . ToArray ( ) ;
435
+ fileChildren . Length . Should ( ) . Be ( 1 ) ;
436
+
437
+ fileChildren [ 0 ] . Label . Should ( ) . Be ( "file1.txt.meta" ) ;
438
+ fileChildren [ 0 ] . Open . Should ( ) . BeTrue ( ) ;
439
+ fileChildren [ 0 ] . Path . Should ( ) . Be ( "file1.txt.meta" ) ;
440
+
441
+ //TODO: Understand this as this is unexpected
442
+ fileChildren [ 0 ] . RepositoryPath . Should ( ) . Be ( @"file1.txt\file1.txt.meta" ) ;
443
+
444
+ fileChildren [ 0 ] . State . Should ( ) . Be ( CommitState . None ) ;
445
+ fileChildren [ 0 ] . State . Should ( ) . Be ( CommitState . None ) ;
446
+ fileChildren [ 0 ] . Target . Should ( ) . Be ( gitCommitTargets [ 1 ] ) ;
447
+
448
+ fileChildren [ 0 ] . Children . Should ( ) . BeEmpty ( ) ;
449
+ }
450
+
291
451
private void InitializeEnvironment ( string repositoryPath , string projectPath )
292
452
{
293
453
var substituteFactory = new SubstituteFactory ( ) ;
0 commit comments