1
1
using System . Collections . Generic ;
2
2
using System . Text . Json ;
3
3
using Amazon . Extensions . Configuration . SystemsManager . Utils ;
4
- using Amazon . SimpleSystemsManagement . Model ;
5
4
using Xunit ;
6
5
7
6
namespace Amazon . Extensions . Configuration . SystemsManager . Tests . Utils
@@ -12,10 +11,10 @@ public class ParameterProcessorUtilTests
12
11
public void ParseJsonParameterSuccessfully ( )
13
12
{
14
13
var result = new Dictionary < string , string > ( ) ;
15
- var parameter = new Parameter { Value = "{\" key\" : \" value\" }" } ;
14
+ var value = "{\" key\" : \" value\" }" ;
16
15
var keyPrefix = "prefix" ;
17
16
18
- ParameterProcessorUtil . ParseJsonParameter ( parameter , keyPrefix , result ) ;
17
+ ParameterProcessorUtil . ParseJsonParameter ( keyPrefix , value , result ) ;
19
18
20
19
Assert . Single ( result ) ;
21
20
Assert . Contains ( "prefix:key" , result . Keys ) ;
@@ -26,30 +25,30 @@ public void ParseJsonParameterSuccessfully()
26
25
public void ParseJsonParameterWithDuplicateKeyThrowsException ( )
27
26
{
28
27
var result = new Dictionary < string , string > { { "prefix:key" , "value" } } ;
29
- var parameter = new Parameter { Value = "{\" key\" : \" newvalue\" }" } ;
28
+ var value = "{\" key\" : \" newvalue\" }" ;
30
29
var keyPrefix = "prefix" ;
31
30
32
- Assert . Throws < DuplicateParameterException > ( ( ) => ParameterProcessorUtil . ParseJsonParameter ( parameter , keyPrefix , result ) ) ;
31
+ Assert . Throws < DuplicateParameterException > ( ( ) => ParameterProcessorUtil . ParseJsonParameter ( keyPrefix , value , result ) ) ;
33
32
}
34
33
35
34
[ Fact ]
36
35
public void ParseJsonParameterForInvalidJsonThrowsException ( )
37
36
{
38
37
var result = new Dictionary < string , string > ( ) ;
39
- var parameter = new Parameter { Value = "invalid json" } ;
38
+ var value = "invalid json" ;
40
39
var keyPrefix = "" ;
41
40
42
- Assert . ThrowsAny < JsonException > ( ( ) => ParameterProcessorUtil . ParseJsonParameter ( parameter , keyPrefix , result ) ) ;
41
+ Assert . ThrowsAny < JsonException > ( ( ) => ParameterProcessorUtil . ParseJsonParameter ( keyPrefix , value , result ) ) ;
43
42
}
44
43
45
44
[ Fact ]
46
45
public void ParseStringListParameterSuccessfully ( )
47
46
{
48
47
var result = new Dictionary < string , string > ( ) ;
49
- var parameter = new Parameter { Value = "value1,value2,value3" } ;
48
+ var value = "value1,value2,value3" ;
50
49
var keyPrefix = "prefix" ;
51
50
52
- ParameterProcessorUtil . ParseStringListParameter ( parameter , keyPrefix , result ) ;
51
+ ParameterProcessorUtil . ParseStringListParameter ( keyPrefix , value , result ) ;
53
52
54
53
Assert . Equal ( 3 , result . Count ) ;
55
54
Assert . Contains ( "prefix:0" , result . Keys ) ;
@@ -64,20 +63,20 @@ public void ParseStringListParameterSuccessfully()
64
63
public void ParseStringListParameterWithDuplicateKeyThrowsException ( )
65
64
{
66
65
var result = new Dictionary < string , string > { { "prefix:0" , "value" } } ;
67
- var parameter = new Parameter { Value = "value1,value2,value3" } ;
66
+ var value = "value1,value2,value3" ;
68
67
var keyPrefix = "prefix" ;
69
68
70
- Assert . Throws < DuplicateParameterException > ( ( ) => ParameterProcessorUtil . ParseStringListParameter ( parameter , keyPrefix , result ) ) ;
69
+ Assert . Throws < DuplicateParameterException > ( ( ) => ParameterProcessorUtil . ParseStringListParameter ( keyPrefix , value , result ) ) ;
71
70
}
72
-
71
+
73
72
[ Fact ]
74
73
public void ParseStringParameterSuccessfully ( )
75
74
{
76
75
var result = new Dictionary < string , string > ( ) ;
77
- var parameter = new Parameter { Value = "stringValue" } ;
76
+ var value = "stringValue" ;
78
77
var key = "myKey" ;
79
78
80
- ParameterProcessorUtil . ParseStringParameter ( parameter , key , result ) ;
79
+ ParameterProcessorUtil . ParseStringParameter ( key , value , result ) ;
81
80
82
81
Assert . Single ( result ) ;
83
82
Assert . Contains ( "myKey" , result . Keys ) ;
@@ -88,11 +87,10 @@ public void ParseStringParameterSuccessfully()
88
87
public void ParseStringParameterWithDuplicateKeyThrowsException ( )
89
88
{
90
89
var result = new Dictionary < string , string > { { "myKey" , "existingValue" } } ;
91
- var parameter = new Parameter { Value = "newValue" } ;
90
+ var value = "newValue" ;
92
91
var key = "myKey" ;
93
92
94
- Assert . Throws < DuplicateParameterException > ( ( ) => ParameterProcessorUtil . ParseStringParameter ( parameter , key , result ) ) ;
93
+ Assert . Throws < DuplicateParameterException > ( ( ) => ParameterProcessorUtil . ParseStringParameter ( key , value , result ) ) ;
95
94
}
96
-
97
95
}
98
96
}
0 commit comments