@@ -225,10 +225,9 @@ public void Can_Deserialize_Empty_Elements_to_Nullable_Values()
225
225
[ Fact ]
226
226
public void Can_Deserialize_Elements_to_Nullable_Values ( )
227
227
{
228
- var culture = CultureInfo . InvariantCulture ;
229
- var doc = CreateXmlWithoutEmptyValues ( culture ) ;
230
-
231
- var xml = new XmlDeserializer ( ) { Culture = culture } ;
228
+ var culture = CultureInfo . InvariantCulture ;
229
+ var doc = CreateXmlWithoutEmptyValues ( culture ) ;
230
+ var xml = new XmlDeserializer ( ) { Culture = culture } ;
232
231
var output = xml . Deserialize < NullableValues > ( new RestResponse { Content = doc } ) ;
233
232
234
233
Assert . NotNull ( output . Id ) ;
@@ -243,24 +242,24 @@ public void Can_Deserialize_Elements_to_Nullable_Values()
243
242
[ Fact ]
244
243
public void Can_Deserialize_Custom_Formatted_Date ( )
245
244
{
246
- var culture = CultureInfo . InvariantCulture ;
245
+ var culture = CultureInfo . InvariantCulture ;
247
246
var format = "dd yyyy MMM, hh:mm ss tt zzz" ;
248
247
var date = new DateTime ( 2010 , 2 , 8 , 11 , 11 , 11 ) ;
249
248
250
249
var doc = new XDocument ( ) ;
251
250
252
251
var root = new XElement ( "Person" ) ;
253
- root . Add ( new XElement ( "StartDate" , date . ToString ( format , culture ) ) ) ;
252
+ root . Add ( new XElement ( "StartDate" , date . ToString ( format , culture ) ) ) ;
254
253
255
254
doc . Add ( root ) ;
256
255
257
- var xml = new XmlDeserializer
258
- {
259
- DateFormat = format ,
260
- Culture = culture
261
- } ;
256
+ var xml = new XmlDeserializer
257
+ {
258
+ DateFormat = format ,
259
+ Culture = culture
260
+ } ;
262
261
263
- var response = new RestResponse { Content = doc . ToString ( ) } ;
262
+ var response = new RestResponse { Content = doc . ToString ( ) } ;
264
263
var output = xml . Deserialize < PersonForXml > ( response ) ;
265
264
266
265
Assert . Equal ( date , output . StartDate ) ;
@@ -515,31 +514,31 @@ public void Can_Deserialize_Boolean_From_String()
515
514
Assert . True ( output . Value ) ;
516
515
}
517
516
518
- [ Fact ]
519
- public void Can_Deserialize_Empty_Elements_With_Attributes_to_Nullable_Values ( )
520
- {
521
- var doc = CreateXmlWithAttributesAndNullValues ( ) ;
517
+ [ Fact ]
518
+ public void Can_Deserialize_Empty_Elements_With_Attributes_to_Nullable_Values ( )
519
+ {
520
+ var doc = CreateXmlWithAttributesAndNullValues ( ) ;
522
521
523
- var xml = new XmlDeserializer ( ) ;
524
- var output = xml . Deserialize < NullableValues > ( new RestResponse { Content = doc } ) ;
522
+ var xml = new XmlDeserializer ( ) ;
523
+ var output = xml . Deserialize < NullableValues > ( new RestResponse { Content = doc } ) ;
525
524
526
- Assert . Null ( output . Id ) ;
527
- Assert . Null ( output . StartDate ) ;
528
- Assert . Null ( output . UniqueId ) ;
529
- }
525
+ Assert . Null ( output . Id ) ;
526
+ Assert . Null ( output . StartDate ) ;
527
+ Assert . Null ( output . UniqueId ) ;
528
+ }
530
529
531
- [ Fact ]
532
- public void Can_Deserialize_Mixture_Of_Empty_Elements_With_Attributes_And_Populated_Elements ( )
533
- {
534
- var doc = CreateXmlWithAttributesAndNullValuesAndPopulatedValues ( ) ;
530
+ [ Fact ]
531
+ public void Can_Deserialize_Mixture_Of_Empty_Elements_With_Attributes_And_Populated_Elements ( )
532
+ {
533
+ var doc = CreateXmlWithAttributesAndNullValuesAndPopulatedValues ( ) ;
535
534
536
- var xml = new XmlDeserializer ( ) ;
537
- var output = xml . Deserialize < NullableValues > ( new RestResponse { Content = doc } ) ;
535
+ var xml = new XmlDeserializer ( ) ;
536
+ var output = xml . Deserialize < NullableValues > ( new RestResponse { Content = doc } ) ;
538
537
539
- Assert . Null ( output . Id ) ;
540
- Assert . Null ( output . StartDate ) ;
541
- Assert . Equal ( new Guid ( GuidString ) , output . UniqueId ) ;
542
- }
538
+ Assert . Null ( output . Id ) ;
539
+ Assert . Null ( output . StartDate ) ;
540
+ Assert . Equal ( new Guid ( GuidString ) , output . UniqueId ) ;
541
+ }
543
542
544
543
private static string CreateUnderscoresXml ( )
545
544
{
@@ -757,9 +756,9 @@ private static string CreateXmlWithoutEmptyValues(CultureInfo culture)
757
756
var root = new XElement ( "NullableValues" ) ;
758
757
759
758
root . Add ( new XElement ( "Id" , 123 ) ,
760
- new XElement ( "StartDate" , new DateTime ( 2010 , 2 , 21 , 9 , 35 , 00 ) . ToString ( culture ) ) ,
761
- new XElement ( "UniqueId" , new Guid ( GuidString ) )
762
- ) ;
759
+ new XElement ( "StartDate" , new DateTime ( 2010 , 2 , 21 , 9 , 35 , 00 ) . ToString ( culture ) ) ,
760
+ new XElement ( "UniqueId" , new Guid ( GuidString ) )
761
+ ) ;
763
762
764
763
doc . Add ( root ) ;
765
764
@@ -788,38 +787,38 @@ private static string CreateXmlWithEmptyInlineList()
788
787
return doc . ToString ( ) ;
789
788
}
790
789
791
- private static string CreateXmlWithAttributesAndNullValues ( )
792
- {
793
- var doc = new XDocument ( ) ;
794
- var root = new XElement ( "NullableValues" ) ;
790
+ private static string CreateXmlWithAttributesAndNullValues ( )
791
+ {
792
+ var doc = new XDocument ( ) ;
793
+ var root = new XElement ( "NullableValues" ) ;
795
794
796
- var idElement = new XElement ( "Id" , null ) ;
797
- idElement . SetAttributeValue ( "SomeAttribute" , "SomeAttribute_Value" ) ;
798
- root . Add ( idElement ,
799
- new XElement ( "StartDate" , null ) ,
800
- new XElement ( "UniqueId" , null )
801
- ) ;
795
+ var idElement = new XElement ( "Id" , null ) ;
796
+ idElement . SetAttributeValue ( "SomeAttribute" , "SomeAttribute_Value" ) ;
797
+ root . Add ( idElement ,
798
+ new XElement ( "StartDate" , null ) ,
799
+ new XElement ( "UniqueId" , null )
800
+ ) ;
802
801
803
- doc . Add ( root ) ;
802
+ doc . Add ( root ) ;
804
803
805
- return doc . ToString ( ) ;
806
- }
804
+ return doc . ToString ( ) ;
805
+ }
807
806
808
- private static string CreateXmlWithAttributesAndNullValuesAndPopulatedValues ( )
809
- {
810
- var doc = new XDocument ( ) ;
811
- var root = new XElement ( "NullableValues" ) ;
807
+ private static string CreateXmlWithAttributesAndNullValuesAndPopulatedValues ( )
808
+ {
809
+ var doc = new XDocument ( ) ;
810
+ var root = new XElement ( "NullableValues" ) ;
812
811
813
- var idElement = new XElement ( "Id" , null ) ;
814
- idElement . SetAttributeValue ( "SomeAttribute" , "SomeAttribute_Value" ) ;
815
- root . Add ( idElement ,
816
- new XElement ( "StartDate" , null ) ,
817
- new XElement ( "UniqueId" , new Guid ( GuidString ) )
818
- ) ;
812
+ var idElement = new XElement ( "Id" , null ) ;
813
+ idElement . SetAttributeValue ( "SomeAttribute" , "SomeAttribute_Value" ) ;
814
+ root . Add ( idElement ,
815
+ new XElement ( "StartDate" , null ) ,
816
+ new XElement ( "UniqueId" , new Guid ( GuidString ) )
817
+ ) ;
819
818
820
- doc . Add ( root ) ;
819
+ doc . Add ( root ) ;
821
820
822
- return doc . ToString ( ) ;
823
- }
821
+ return doc . ToString ( ) ;
822
+ }
824
823
}
825
824
}
0 commit comments