@@ -9,8 +9,9 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Core.Services;
9
9
10
10
public partial class DocumentNavigationServiceTests
11
11
{
12
- [ Test ]
13
- public async Task Structure_Can_Rebuild ( )
12
+ [ TestCase ( 1 , TestName = "Structure_Can_Rebuild" ) ]
13
+ [ TestCase ( 2 , TestName = "Structure_Can_Rebuild_MultipleTimes" ) ]
14
+ public async Task Structure_Can_Rebuild ( int numberOfRebuilds )
14
15
{
15
16
// Arrange
16
17
Guid nodeKey = Root . Key ;
@@ -21,6 +22,7 @@ public async Task Structure_Can_Rebuild()
21
22
DocumentNavigationQueryService . TryGetDescendantsKeys ( nodeKey , out IEnumerable < Guid > originalDescendantsKeys ) ;
22
23
DocumentNavigationQueryService . TryGetAncestorsKeys ( nodeKey , out IEnumerable < Guid > originalAncestorsKeys ) ;
23
24
DocumentNavigationQueryService . TryGetSiblingsKeys ( nodeKey , out IEnumerable < Guid > originalSiblingsKeys ) ;
25
+ DocumentNavigationQueryService . TryGetRootKeys ( out IEnumerable < Guid > originalRouteKeys ) ;
24
26
25
27
// In-memory navigation structure is empty here
26
28
var newDocumentNavigationService = new DocumentNavigationService (
@@ -30,14 +32,18 @@ public async Task Structure_Can_Rebuild()
30
32
var initialNodeExists = newDocumentNavigationService . TryGetParentKey ( nodeKey , out _ ) ;
31
33
32
34
// Act
33
- await newDocumentNavigationService . RebuildAsync ( ) ;
35
+ for ( int i = 0 ; i < numberOfRebuilds ; i ++ )
36
+ {
37
+ await newDocumentNavigationService . RebuildAsync ( ) ;
38
+ }
34
39
35
40
// Capture rebuilt state
36
41
var nodeExists = newDocumentNavigationService . TryGetParentKey ( nodeKey , out Guid ? parentKeyFromRebuild ) ;
37
42
newDocumentNavigationService . TryGetChildrenKeys ( nodeKey , out IEnumerable < Guid > childrenKeysFromRebuild ) ;
38
43
newDocumentNavigationService . TryGetDescendantsKeys ( nodeKey , out IEnumerable < Guid > descendantsKeysFromRebuild ) ;
39
44
newDocumentNavigationService . TryGetAncestorsKeys ( nodeKey , out IEnumerable < Guid > ancestorsKeysFromRebuild ) ;
40
45
newDocumentNavigationService . TryGetSiblingsKeys ( nodeKey , out IEnumerable < Guid > siblingsKeysFromRebuild ) ;
46
+ newDocumentNavigationService . TryGetRootKeys ( out IEnumerable < Guid > routeKeysFromRebuild ) ;
41
47
42
48
// Assert
43
49
Assert . Multiple ( ( ) =>
@@ -53,11 +59,13 @@ public async Task Structure_Can_Rebuild()
53
59
CollectionAssert . AreEquivalent ( originalDescendantsKeys , descendantsKeysFromRebuild ) ;
54
60
CollectionAssert . AreEquivalent ( originalAncestorsKeys , ancestorsKeysFromRebuild ) ;
55
61
CollectionAssert . AreEquivalent ( originalSiblingsKeys , siblingsKeysFromRebuild ) ;
62
+ CollectionAssert . AreEquivalent ( originalRouteKeys , routeKeysFromRebuild ) ;
56
63
} ) ;
57
64
}
58
65
59
- [ Test ]
60
- public async Task Bin_Structure_Can_Rebuild ( )
66
+ [ TestCase ( 1 , TestName = "Bin_Structure_Can_Rebuild" ) ]
67
+ [ TestCase ( 2 , TestName = "Bin_Structure_Can_Rebuild_MultipleTimes" ) ]
68
+ public async Task Bin_Structure_Can_Rebuild ( int numberOfRebuilds )
61
69
{
62
70
// Arrange
63
71
Guid nodeKey = Root . Key ;
@@ -69,6 +77,7 @@ public async Task Bin_Structure_Can_Rebuild()
69
77
DocumentNavigationQueryService . TryGetDescendantsKeysInBin ( nodeKey , out IEnumerable < Guid > originalDescendantsKeys ) ;
70
78
DocumentNavigationQueryService . TryGetAncestorsKeysInBin ( nodeKey , out IEnumerable < Guid > originalAncestorsKeys ) ;
71
79
DocumentNavigationQueryService . TryGetSiblingsKeysInBin ( nodeKey , out IEnumerable < Guid > originalSiblingsKeys ) ;
80
+ DocumentNavigationQueryService . TryGetRootKeys ( out IEnumerable < Guid > originalRouteKeys ) ;
72
81
73
82
// In-memory navigation structure is empty here
74
83
var newDocumentNavigationService = new DocumentNavigationService (
@@ -78,14 +87,18 @@ public async Task Bin_Structure_Can_Rebuild()
78
87
var initialNodeExists = newDocumentNavigationService . TryGetParentKeyInBin ( nodeKey , out _ ) ;
79
88
80
89
// Act
81
- await newDocumentNavigationService . RebuildBinAsync ( ) ;
90
+ for ( int i = 0 ; i < numberOfRebuilds ; i ++ )
91
+ {
92
+ await newDocumentNavigationService . RebuildBinAsync ( ) ;
93
+ }
82
94
83
95
// Capture rebuilt state
84
96
var nodeExists = newDocumentNavigationService . TryGetParentKeyInBin ( nodeKey , out Guid ? parentKeyFromRebuild ) ;
85
97
newDocumentNavigationService . TryGetChildrenKeysInBin ( nodeKey , out IEnumerable < Guid > childrenKeysFromRebuild ) ;
86
98
newDocumentNavigationService . TryGetDescendantsKeysInBin ( nodeKey , out IEnumerable < Guid > descendantsKeysFromRebuild ) ;
87
99
newDocumentNavigationService . TryGetAncestorsKeysInBin ( nodeKey , out IEnumerable < Guid > ancestorsKeysFromRebuild ) ;
88
100
newDocumentNavigationService . TryGetSiblingsKeysInBin ( nodeKey , out IEnumerable < Guid > siblingsKeysFromRebuild ) ;
101
+ newDocumentNavigationService . TryGetRootKeys ( out IEnumerable < Guid > routeKeysFromRebuild ) ;
89
102
90
103
// Assert
91
104
Assert . Multiple ( ( ) =>
@@ -101,6 +114,7 @@ public async Task Bin_Structure_Can_Rebuild()
101
114
CollectionAssert . AreEquivalent ( originalDescendantsKeys , descendantsKeysFromRebuild ) ;
102
115
CollectionAssert . AreEquivalent ( originalAncestorsKeys , ancestorsKeysFromRebuild ) ;
103
116
CollectionAssert . AreEquivalent ( originalSiblingsKeys , siblingsKeysFromRebuild ) ;
117
+ CollectionAssert . AreEquivalent ( originalRouteKeys , routeKeysFromRebuild ) ;
104
118
} ) ;
105
119
}
106
120
}
0 commit comments