File tree 2 files changed +36
-6
lines changed
src/Microsoft.AspNetCore.Components
test/Microsoft.AspNetCore.Components.Test
2 files changed +36
-6
lines changed Original file line number Diff line number Diff line change @@ -199,10 +199,10 @@ internal void CaptureSnapshot(ArrayBuilder<RenderTreeFrame> builder)
199
199
}
200
200
201
201
/// <summary>
202
- ///
202
+ /// Creates a new <see cref="ParameterCollection"/> from the given <see cref="IDictionary{TKey, TValue}"/>.
203
203
/// </summary>
204
- /// <param name="parameters"></param>
205
- /// <returns></returns>
204
+ /// <param name="parameters">The <see cref="IDictionary{TKey, TValue}"/> with the parameters. </param>
205
+ /// <returns>A <see cref="ParameterCollection"/>. </returns>
206
206
public static ParameterCollection FromDictionary ( Dictionary < string , object > parameters )
207
207
{
208
208
var frames = new RenderTreeFrame [ parameters . Count + 1 ] ;
Original file line number Diff line number Diff line change 1
1
// Copyright (c) .NET Foundation. All rights reserved.
2
2
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3
3
4
- using Microsoft . AspNetCore . Components ;
5
- using Microsoft . AspNetCore . Components . Rendering ;
6
- using Microsoft . AspNetCore . Components . RenderTree ;
7
4
using System ;
8
5
using System . Collections . Generic ;
9
6
using System . Threading . Tasks ;
7
+ using Microsoft . AspNetCore . Components . Rendering ;
8
+ using Microsoft . AspNetCore . Components . RenderTree ;
10
9
using Xunit ;
11
10
12
11
namespace Microsoft . AspNetCore . Components . Test
@@ -240,6 +239,37 @@ public void ThrowsIfTryGetExistingValueWithIncorrectType()
240
239
} ) ;
241
240
}
242
241
242
+ [ Fact ]
243
+ public void FromDictionary_CanBeInitializedWithEmptyDictionary ( )
244
+ {
245
+ // Arrange
246
+ var dictionary = new Dictionary < string , object > ( ) ;
247
+
248
+ // Act
249
+ var collection = ParameterCollection . FromDictionary ( dictionary ) ;
250
+
251
+ // Assert
252
+ Assert . Empty ( collection . ToDictionary ( ) ) ;
253
+ }
254
+
255
+ [ Fact ]
256
+ public void FromDictionary_RoundTrips ( )
257
+ {
258
+ // Arrange
259
+ var dictionary = new Dictionary < string , object >
260
+ {
261
+ [ "IntValue" ] = 1 ,
262
+ [ "StringValue" ] = "String"
263
+ } ;
264
+
265
+ // Act
266
+ var collection = ParameterCollection . FromDictionary ( dictionary ) ;
267
+
268
+ // Assert
269
+ Assert . Equal ( dictionary , collection . ToDictionary ( ) ) ;
270
+ }
271
+
272
+
243
273
[ Fact ]
244
274
public void CanConvertToReadOnlyDictionary ( )
245
275
{
You can’t perform that action at this time.
0 commit comments