11using System . Collections . Generic ;
22using Newtonsoft . Json ;
33using Newtonsoft . Json . Linq ;
4- using OpenStack . Networking . v2 . Serialization ;
5- using OpenStack . Serialization ;
64using Xunit ;
75
86namespace OpenStack . Networking . v2
@@ -12,24 +10,27 @@ public class DHCPOptionConverterTests
1210 [ Fact ]
1311 public void Serialize ( )
1412 {
15- var options = new Dictionary < string , string >
13+ var input = new PortCreateDefinition ( null )
1614 {
17- { "a" , "stuff" } ,
18- { "b" , "things" }
15+ DHCPOptions =
16+ {
17+ { "a" , "stuff" } ,
18+ { "b" , "things" }
19+ }
1920 } ;
2021
21- string result = OpenStackNet . Configuration . FlurlHttpSettings . JsonSerializer . Serialize ( options , Formatting . None , new DHCPOptionsConverter ( ) ) ;
22+ string result = OpenStackNet . Configuration . FlurlHttpSettings . JsonSerializer . Serialize ( input ) ;
2223
23- string expectedJson = JArray . Parse ( "[{'opt_name':'a','opt_value':'stuff'},{'opt_name':'b','opt_value':'things'}]" ) . ToString ( Formatting . None ) ;
24+ string expectedJson = JObject . Parse ( "{'port':{'extra_dhcp_opts': [{'opt_name':'a','opt_value':'stuff'},{'opt_name':'b','opt_value':'things'}]}} " ) . ToString ( Formatting . None ) ;
2425 Assert . Equal ( expectedJson , result ) ;
2526 }
2627
2728 [ Fact ]
2829 public void Deserialize ( )
2930 {
30- string json = JArray . Parse ( "[{'opt_name':'a','opt_value':'stuff'},{'opt_name':'b','opt_value':'things'}]" ) . ToString ( Formatting . None ) ;
31+ string json = JObject . Parse ( "{'port':{'extra_dhcp_opts': [{'opt_name':'a','opt_value':'stuff'},{'opt_name':'b','opt_value':'things'}]}} " ) . ToString ( Formatting . None ) ;
3132
32- var result = OpenStackNet . Configuration . FlurlHttpSettings . JsonSerializer . Deserialize < Dictionary < string , string > > ( json , new DHCPOptionsConverter ( ) ) ;
33+ var result = OpenStackNet . Configuration . FlurlHttpSettings . JsonSerializer . Deserialize < PortCreateDefinition > ( json ) . DHCPOptions ;
3334
3435 Assert . NotNull ( result ) ;
3536 Assert . Equal ( 2 , result . Count ) ;
@@ -43,8 +44,6 @@ public void Deserialize()
4344 [ Fact ]
4445 public void OpenStackNet_UsesDHCPOptionConverter ( )
4546 {
46- OpenStackNet . Configure ( ) ;
47-
4847 var port = new Port
4948 {
5049 DHCPOptions = new Dictionary < string , string >
0 commit comments