@@ -18,66 +18,66 @@ public class BookTest
1818 } ,
1919 Url = new Uri ( "http://www.barnesandnoble.com/store/info/offer/JDSalinger" ) ,
2020 WorkExample = new List < CreativeWork > ( )
21+ {
22+ new Book ( )
2123 {
22- new Book ( )
24+ Isbn = "031676948" ,
25+ BookEdition = "2nd Edition" ,
26+ BookFormat = BookFormatType . Hardcover ,
27+ PotentialAction = new ReadAction ( )
2328 {
24- Isbn = "031676948" ,
25- BookEdition = "2nd Edition" ,
26- BookFormat = BookFormatType . Hardcover ,
27- PotentialAction = new ReadAction ( )
29+ Target = new EntryPoint ( )
2830 {
29- Target = new EntryPoint ( )
30- {
31- UrlTemplate = "http://www.barnesandnoble.com/store/info/offer/0316769487?purchase=true" ,
32- ActionPlatform = new List < Uri > ( )
33- {
34- new Uri ( "http://schema.org/DesktopWebPlatform" ) ,
35- new Uri ( "http://schema.org/IOSPlatform" ) ,
36- new Uri ( "http://schema.org/AndroidPlatform" )
37- }
38- } ,
39- ExpectsAcceptanceOf = new Offer ( )
31+ UrlTemplate = "http://www.barnesandnoble.com/store/info/offer/0316769487?purchase=true" ,
32+ ActionPlatform = new List < Uri > ( )
4033 {
41- Price = 6.99M ,
42- PriceCurrency = "USD" ,
43- EligibleRegion = new Country ( )
44- {
45- Name = "US"
46- } ,
47- Availability = ItemAvailability . InStock
34+ new Uri ( "http://schema.org/DesktopWebPlatform" ) ,
35+ new Uri ( "http://schema.org/IOSPlatform" ) ,
36+ new Uri ( "http://schema.org/AndroidPlatform" )
4837 }
4938 } ,
50- } ,
51- new Book ( )
52- {
53- Isbn = "031676947" ,
54- BookEdition = "1st Edition" ,
55- BookFormat = BookFormatType . EBook ,
56- PotentialAction = new ReadAction ( )
39+ ExpectsAcceptanceOf = new Offer ( )
5740 {
58- Target = new EntryPoint ( )
41+ Price = 6.99M ,
42+ PriceCurrency = "USD" ,
43+ EligibleRegion = new Country ( )
5944 {
60- UrlTemplate = "http://www.barnesandnoble.com/store/info/offer/031676947?purchase=true" ,
61- ActionPlatform = new List < Uri > ( )
62- {
63- new Uri ( "http://schema.org/DesktopWebPlatform" ) ,
64- new Uri ( "http://schema.org/IOSPlatform" ) ,
65- new Uri ( "http://schema.org/AndroidPlatform" )
66- }
45+ Name = "US"
6746 } ,
68- ExpectsAcceptanceOf = new Offer ( )
47+ Availability = ItemAvailability . InStock
48+ }
49+ } ,
50+ } ,
51+ new Book ( )
52+ {
53+ Isbn = "031676947" ,
54+ BookEdition = "1st Edition" ,
55+ BookFormat = BookFormatType . EBook ,
56+ PotentialAction = new ReadAction ( )
57+ {
58+ Target = new EntryPoint ( )
59+ {
60+ UrlTemplate = "http://www.barnesandnoble.com/store/info/offer/031676947?purchase=true" ,
61+ ActionPlatform = new List < Uri > ( )
6962 {
70- Price = 1.99M ,
71- PriceCurrency = "USD" ,
72- EligibleRegion = new Country ( )
73- {
74- Name = "UK"
75- } ,
76- Availability = ItemAvailability . InStock
63+ new Uri ( "http://schema.org/DesktopWebPlatform" ) ,
64+ new Uri ( "http://schema.org/IOSPlatform" ) ,
65+ new Uri ( "http://schema.org/AndroidPlatform" )
7766 }
7867 } ,
79- }
68+ ExpectsAcceptanceOf = new Offer ( )
69+ {
70+ Price = 1.99M ,
71+ PriceCurrency = "USD" ,
72+ EligibleRegion = new Country ( )
73+ {
74+ Name = "UK"
75+ } ,
76+ Availability = ItemAvailability . InStock
77+ }
78+ } ,
8079 }
80+ }
8181 } ;
8282
8383 private readonly string json =
@@ -158,5 +158,28 @@ public void ToString_BookGoogleStructuredData_ReturnsExpectedJsonLd() =>
158158 [ Fact ]
159159 public void Deserializing_BookJsonLd_ReturnsBook ( ) =>
160160 Assert . Equal ( this . book . ToString ( ) , JsonConvert . DeserializeObject < Book > ( this . json ) . ToString ( ) ) ;
161+
162+ [ Fact ]
163+ public void Deserializing_HasPersonAsAuthor_OrganizationIsNullAndHasPerson ( )
164+ {
165+ var json =
166+ "{" +
167+ "\" @context\" : \" http://schema.org\" ," +
168+ "\" @type\" : \" Book\" ," +
169+ "\" author\" : [" +
170+ "{" +
171+ "\" @type\" : \" Person\" ," +
172+ "\" name\" : \" NameOfPerson1\" ," +
173+ "}," +
174+ "]," +
175+ "\" typicalAgeRange\" : \" 14\" ," +
176+ "\" isbn\" : \" 3333\" " +
177+ "}" ;
178+ var book = JsonConvert . DeserializeObject < Book > ( json ) ;
179+
180+ Assert . Equal ( 0 , book . Author . Value . Value1 . Count ) ;
181+ var person = Assert . Single ( book . Author . Value . Value2 ) ;
182+ Assert . Equal ( "NameOfPerson1" , person . Name ) ;
183+ }
161184 }
162185}
0 commit comments