@@ -55,16 +55,17 @@ public async Task PersistAsync_CanPersistMultipleComponentsOfSameType_WhenParent
5555 NullLogger < ComponentStatePersistenceManager > . Instance ,
5656 new ServiceCollection ( ) . BuildServiceProvider ( ) ) ;
5757
58+ persistenceManager . State . InitializeExistingState ( state , RestoreContext . InitialValue ) ;
59+
5860 var renderer = new TestRenderer ( ) ;
5961 var component1 = new TestComponent { State = "state1" } ;
6062 var component2 = new TestComponent { State = "state2" } ;
6163
6264 var parentComponent = new ParentComponent ( ) ;
6365
64- var componentStates1 = CreateComponentState ( renderer , [ ( component1 , "key1" ) ] , parentComponent ) ;
65- var componentStates2 = CreateComponentState ( renderer , [ ( component2 , "key2" ) ] , parentComponent ) ;
66- var componentState1 = componentStates1 . First ( ) ;
67- var componentState2 = componentStates2 . First ( ) ;
66+ var componentStates = CreateComponentState ( renderer , [ ( component1 , "key1" ) , ( component2 , "key2" ) ] , parentComponent ) ;
67+ var componentState1 = componentStates [ 0 ] ;
68+ var componentState2 = componentStates [ 1 ] ;
6869
6970 var cascadingParameterInfo = CreateCascadingParameterInfo ( nameof ( TestComponent . State ) , typeof ( string ) ) ;
7071
@@ -109,16 +110,17 @@ public async Task PersistAsync_CanPersistMultipleComponentsOfSameType_SupportsDi
109110 NullLogger < ComponentStatePersistenceManager > . Instance ,
110111 new ServiceCollection ( ) . BuildServiceProvider ( ) ) ;
111112
113+ persistenceManager . State . InitializeExistingState ( state , RestoreContext . InitialValue ) ;
114+
112115 var renderer = new TestRenderer ( ) ;
113116 var component1 = new TestComponent { State = "state1" } ;
114117 var component2 = new TestComponent { State = "state2" } ;
115118
116119 var parentComponent = new ParentComponent ( ) ;
117120
118- var componentStates1 = CreateComponentState ( renderer , [ ( component1 , componentKey1 ) ] , parentComponent ) ;
119- var componentStates2 = CreateComponentState ( renderer , [ ( component2 , componentKey2 ) ] , parentComponent ) ;
120- var componentState1 = componentStates1 . First ( ) ;
121- var componentState2 = componentStates2 . First ( ) ;
121+ var componentStates = CreateComponentState ( renderer , [ ( component1 , componentKey1 ) , ( component2 , componentKey2 ) ] , parentComponent ) ;
122+ var componentState1 = componentStates [ 0 ] ;
123+ var componentState2 = componentStates [ 1 ] ;
122124
123125 var cascadingParameterInfo = CreateCascadingParameterInfo ( nameof ( TestComponent . State ) , typeof ( string ) ) ;
124126
@@ -161,14 +163,15 @@ public async Task PersistenceFails_IfMultipleComponentsOfSameType_TryToPersistDa
161163 logger ,
162164 new ServiceCollection ( ) . BuildServiceProvider ( ) ) ;
163165
166+ persistenceManager . State . InitializeExistingState ( state , RestoreContext . InitialValue ) ;
167+
164168 var renderer = new TestRenderer ( ) ;
165169 var component1 = new TestComponent { State = "state1" } ;
166170 var component2 = new TestComponent { State = "state2" } ;
167171
168- var componentStates1 = CreateComponentState ( renderer , [ ( component1 , null ) ] , null ) ;
169- var componentStates2 = CreateComponentState ( renderer , [ ( component2 , null ) ] , null ) ;
170- var componentState1 = componentStates1 . First ( ) ;
171- var componentState2 = componentStates2 . First ( ) ;
172+ var componentStates = CreateComponentState ( renderer , [ ( component1 , null ) , ( component2 , null ) ] , null ) ;
173+ var componentState1 = componentStates [ 0 ] ;
174+ var componentState2 = componentStates [ 1 ] ;
172175
173176 var cascadingParameterInfo = CreateCascadingParameterInfo ( nameof ( TestComponent . State ) , typeof ( string ) ) ;
174177
@@ -210,16 +213,17 @@ public async Task PersistentceFails_IfMultipleComponentsOfSameType_TryToPersistD
210213 logger ,
211214 new ServiceCollection ( ) . BuildServiceProvider ( ) ) ;
212215
216+ persistenceManager . State . InitializeExistingState ( state , RestoreContext . InitialValue ) ;
217+
213218 var renderer = new TestRenderer ( ) ;
214219 var component1 = new TestComponent { State = "state1" } ;
215220 var component2 = new TestComponent { State = "state2" } ;
216221
217222 var parentComponent = new TestComponent ( ) ;
218223
219- var componentStates1 = CreateComponentState ( renderer , [ ( component1 , null ) ] , parentComponent ) ;
220- var componentStates2 = CreateComponentState ( renderer , [ ( component2 , null ) ] , parentComponent ) ;
221- var componentState1 = componentStates1 . First ( ) ;
222- var componentState2 = componentStates2 . First ( ) ;
224+ var componentStates = CreateComponentState ( renderer , [ ( component1 , null ) , ( component2 , null ) ] , parentComponent ) ;
225+ var componentState1 = componentStates [ 0 ] ;
226+ var componentState2 = componentStates [ 1 ] ;
223227
224228 var cascadingParameterInfo = CreateCascadingParameterInfo ( nameof ( TestComponent . State ) , typeof ( string ) ) ;
225229
@@ -247,16 +251,17 @@ public async Task PersistenceFails_MultipleComponentsUseTheSameKey()
247251 logger ,
248252 new ServiceCollection ( ) . BuildServiceProvider ( ) ) ;
249253
254+ persistenceManager . State . InitializeExistingState ( state , RestoreContext . InitialValue ) ;
255+
250256 var renderer = new TestRenderer ( ) ;
251257 var component1 = new TestComponent { State = "state1" } ;
252258 var component2 = new TestComponent { State = "state2" } ;
253259
254260 var parentComponent = new ParentComponent ( ) ;
255261
256- var componentStates1 = CreateComponentState ( renderer , [ ( component1 , "key1" ) ] , parentComponent ) ;
257- var componentStates2 = CreateComponentState ( renderer , [ ( component2 , "key1" ) ] , parentComponent ) ;
258- var componentState1 = componentStates1 . First ( ) ;
259- var componentState2 = componentStates2 . First ( ) ;
262+ var componentStates = CreateComponentState ( renderer , [ ( component1 , "key1" ) , ( component2 , "key1" ) ] , parentComponent ) ;
263+ var componentState1 = componentStates [ 0 ] ;
264+ var componentState2 = componentStates [ 1 ] ;
260265
261266 var cascadingParameterInfo = CreateCascadingParameterInfo ( nameof ( TestComponent . State ) , typeof ( string ) ) ;
262267
@@ -285,16 +290,17 @@ public async Task PersistenceFails_MultipleComponentsUseInvalidKeyTypes(object c
285290 logger ,
286291 new ServiceCollection ( ) . BuildServiceProvider ( ) ) ;
287292
293+ persistenceManager . State . InitializeExistingState ( state , RestoreContext . InitialValue ) ;
294+
288295 var renderer = new TestRenderer ( ) ;
289296 var component1 = new TestComponent { State = "state1" } ;
290297 var component2 = new TestComponent { State = "state2" } ;
291298
292299 var parentComponent = new ParentComponent ( ) ;
293300
294- var componentStates1 = CreateComponentState ( renderer , [ ( component1 , componentKeyType1 ) ] , parentComponent ) ;
295- var componentStates2 = CreateComponentState ( renderer , [ ( component2 , componentKeyType2 ) ] , parentComponent ) ;
296- var componentState1 = componentStates1 . First ( ) ;
297- var componentState2 = componentStates2 . First ( ) ;
301+ var componentStates = CreateComponentState ( renderer , [ ( component1 , componentKeyType1 ) , ( component2 , componentKeyType2 ) ] , parentComponent ) ;
302+ var componentState1 = componentStates [ 0 ] ;
303+ var componentState2 = componentStates [ 1 ] ;
298304
299305 var cascadingParameterInfo = CreateCascadingParameterInfo ( nameof ( TestComponent . State ) , typeof ( string ) ) ;
300306
0 commit comments