11using System . Text . Json ;
2- using FluentAssertions ;
2+ using Shouldly ;
33using FluentDataBuilder . Json ;
4+ using FluentDataBuilder . TestsShared . Extensions ;
45
56namespace FluentDataBuilder . ExtensionTests . Json ;
67
@@ -23,8 +24,8 @@ public void Build_WithChildObject_Returns()
2324
2425 string result = jsonResult . RootElement . GetRawText ( ) ;
2526
26- result . Should ( ) . NotBeNullOrEmpty ( ) ;
27- result . Should ( ) . Be ( "{\" id\" :\" 7c27a562-d405-4b22-9ade-37503bed6014\" ,\" name\" :\" John Doe\" ,\" editor\" :{\" typevalue\" :\" a object\" ,\" numbervalue\" :55865,\" booleanvalue\" :true}}" ) ;
27+ result . ShouldNotBeNullOrEmpty ( ) ;
28+ result . ShouldBe ( "{\" id\" :\" 7c27a562-d405-4b22-9ade-37503bed6014\" ,\" name\" :\" John Doe\" ,\" editor\" :{\" typevalue\" :\" a object\" ,\" numbervalue\" :55865,\" booleanvalue\" :true}}" ) ;
2829 }
2930
3031 [ TestMethod ]
@@ -39,8 +40,8 @@ public void Build_WithSimpleObject_Returns()
3940
4041 string result = jsonResult . RootElement . GetRawText ( ) ;
4142
42- result . Should ( ) . NotBeNullOrEmpty ( ) ;
43- result . Should ( ) . Be ( "{\" name\" :\" this is a test\" ,\" number\" :123}" ) ;
43+ result . ShouldNotBeNullOrEmpty ( ) ;
44+ result . ShouldBe ( "{\" name\" :\" this is a test\" ,\" number\" :123}" ) ;
4445 }
4546
4647 [ TestMethod ]
@@ -55,8 +56,8 @@ public void Build_WithStringList_Returns()
5556
5657 string result = jsonResult . RootElement . GetRawText ( ) ;
5758
58- result . Should ( ) . NotBeNullOrEmpty ( ) ;
59- result . Should ( ) . Be ( "{\" name\" :\" this is a test\" ,\" array\" :[\" this\" ,\" is\" ,\" a\" ,\" test\" ]}" ) ;
59+ result . ShouldNotBeNullOrEmpty ( ) ;
60+ result . ShouldBe ( "{\" name\" :\" this is a test\" ,\" array\" :[\" this\" ,\" is\" ,\" a\" ,\" test\" ]}" ) ;
6061 }
6162
6263 [ TestMethod ]
@@ -71,8 +72,8 @@ public void Build_WithStringArray_Returns()
7172
7273 string result = jsonResult . RootElement . GetRawText ( ) ;
7374
74- result . Should ( ) . NotBeNullOrEmpty ( ) ;
75- result . Should ( ) . Be ( "{\" name\" :\" this is a test\" ,\" array\" :[\" this\" ,\" is\" ,\" a\" ,\" test\" ]}" ) ;
75+ result . ShouldNotBeNullOrEmpty ( ) ;
76+ result . ShouldBe ( "{\" name\" :\" this is a test\" ,\" array\" :[\" this\" ,\" is\" ,\" a\" ,\" test\" ]}" ) ;
7677 }
7778
7879 [ TestMethod ]
@@ -87,8 +88,8 @@ public void Build_WithMixedArray_Returns()
8788
8889 string result = jsonResult . RootElement . GetRawText ( ) ;
8990
90- result . Should ( ) . NotBeNullOrEmpty ( ) ;
91- result . Should ( ) . Be ( "{\" name\" :\" this is a test\" ,\" array\" :[\" this\" ,123,true,456.78]}" ) ;
91+ result . ShouldNotBeNullOrEmpty ( ) ;
92+ result . ShouldBe ( "{\" name\" :\" this is a test\" ,\" array\" :[\" this\" ,123,true,456.78]}" ) ;
9293 }
9394
9495 [ TestMethod ]
@@ -103,8 +104,8 @@ public void Build_WithNumericIntArray_Returns()
103104
104105 string result = jsonResult . RootElement . GetRawText ( ) ;
105106
106- result . Should ( ) . NotBeNullOrEmpty ( ) ;
107- result . Should ( ) . Be ( "{\" name\" :\" this is a test\" ,\" array\" :[12,34,56,78]}" ) ;
107+ result . ShouldNotBeNullOrEmpty ( ) ;
108+ result . ShouldBe ( "{\" name\" :\" this is a test\" ,\" array\" :[12,34,56,78]}" ) ;
108109 }
109110
110111 [ TestMethod ]
@@ -119,8 +120,8 @@ public void Build_WithNumericDoubleArray_Returns()
119120
120121 string result = jsonResult . RootElement . GetRawText ( ) ;
121122
122- result . Should ( ) . NotBeNullOrEmpty ( ) ;
123- result . Should ( ) . Be ( "{\" name\" :\" this is a test\" ,\" array\" :[12.34,34,56.78,78.901]}" ) ;
123+ result . ShouldNotBeNullOrEmpty ( ) ;
124+ result . ShouldBe ( "{\" name\" :\" this is a test\" ,\" array\" :[12.34,34,56.78,78.901]}" ) ;
124125 }
125126
126127 [ TestMethod ]
@@ -147,8 +148,8 @@ public void Build_WithArrayWithAllDataTypes_Returns()
147148
148149 string result = jsonResult . RootElement . GetRawText ( ) ;
149150
150- result . Should ( ) . NotBeNullOrEmpty ( ) ;
151- result . Should ( ) . Be ( "{\" name\" :\" this is a test\" ,\" array\" :[15,15.123412341234,16.123413,false,9.123412341234,\" test\" ,\" x\" ,9876,9876]}" ) ;
151+ result . ShouldNotBeNullOrEmpty ( ) ;
152+ result . ShouldBe ( "{\" name\" :\" this is a test\" ,\" array\" :[15,15.123412341234,16.123413,false,9.123412341234,\" test\" ,\" x\" ,9876,9876]}" ) ;
152153 }
153154
154155 [ TestMethod ]
@@ -157,8 +158,8 @@ public void LoadFrom_WithJsonDocumentNull_Returns()
157158 JsonDocument ? json = null ;
158159 IDataBuilder builder = new DataBuilder ( ) . LoadFrom ( json ! ) ;
159160
160- builder . Should ( ) . NotBeNull ( ) ;
161- builder . GetProperties ( ) . Count . Should ( ) . Be ( 0 ) ;
161+ builder . ShouldNotBeNull ( ) ;
162+ builder . GetProperties ( ) . Count . ShouldBe ( 0 ) ;
162163 }
163164
164165 [ TestMethod ]
@@ -196,25 +197,25 @@ public void LoadFrom_WithSimpleJson_Returns()
196197
197198 IDataBuilder builder = new DataBuilder ( ) . LoadFrom ( json ) ;
198199
199- builder . Should ( ) . NotBeNull ( ) ;
200+ builder . ShouldNotBeNull ( ) ;
200201 var properties = builder . GetProperties ( ) ;
201- properties . Count . Should ( ) . Be ( 7 ) ;
202- properties [ "name" ] . Should ( ) . Be ( "this is a test" ) ;
203- properties [ "number" ] . Should ( ) . Be ( 123 ) ;
204- properties [ "decimal" ] . Should ( ) . Be ( 123.45 ) ;
205- properties [ "boolean" ] . Should ( ) . Be ( true ) ;
206- properties [ "null" ] . Should ( ) . BeNull ( ) ;
207- properties [ "array" ] . Should ( ) . BeOfType < object [ ] > ( ) ;
208- properties [ "array" ] . Should ( ) . BeEquivalentTo ( new List < string > { "this" , "is" , "a" , "test" } ) ;
209- properties [ "object" ] . Should ( ) . BeOfType < Dictionary < string , object > > ( ) ;
210- properties [ "object" ] . Should ( ) . BeEquivalentTo ( new Dictionary < string , object >
202+ properties . Count . ShouldBe ( 7 ) ;
203+ properties [ "name" ] . ShouldBe ( "this is a test" ) ;
204+ properties [ "number" ] . ShouldBe ( 123 ) ;
205+ properties [ "decimal" ] . ShouldBe ( 123.45 ) ;
206+ properties [ "boolean" ] . ShouldBe ( true ) ;
207+ properties [ "null" ] . ShouldBeNull ( ) ;
208+ properties [ "array" ] . ShouldBeOfType < object [ ] > ( ) ;
209+ properties [ "array" ] . ShouldBeEquivalentTo ( new object [ ] { "this" , "is" , "a" , "test" } ) ;
210+ properties [ "object" ] . ShouldBeEqualTo < Dictionary < string , object > > ( dict =>
211211 {
212- { "name" , "this is a test" } ,
213- { "number" , 123 } ,
214- { "decimal" , 123.45 } ,
215- { "boolean" , true } ,
216- { "null" , null ! } ,
217- { "array" , new List < string > { "this" , "is" , "a" , "test" } }
212+ dict . Count . ShouldBe ( 6 ) ;
213+ dict . ShouldContain ( "name" , "this is a test" ) ;
214+ dict . ShouldContain ( "number" , 123 ) ;
215+ dict . ShouldContain ( "decimal" , 123.45 ) ;
216+ dict . ShouldContain ( "boolean" , true ) ;
217+ dict . ShouldContain ( "null" , null ! ) ;
218+ dict . ShouldContain ( "array" , new object [ ] { "this" , "is" , "a" , "test" } ) ;
218219 } ) ;
219220 }
220221
@@ -224,8 +225,8 @@ public void LoadFrom_WithStringNull_Returns()
224225 string ? json = null ;
225226 IDataBuilder builder = new DataBuilder ( ) . LoadFrom ( json ! ) ;
226227
227- builder . Should ( ) . NotBeNull ( ) ;
228- builder . GetProperties ( ) . Count . Should ( ) . Be ( 0 ) ;
228+ builder . ShouldNotBeNull ( ) ;
229+ builder . GetProperties ( ) . Count . ShouldBe ( 0 ) ;
229230 }
230231
231232 [ TestMethod ]
@@ -262,25 +263,25 @@ public void LoadFrom_WithSimpleJsonString_Returns()
262263 }
263264 """ ) ;
264265
265- builder . Should ( ) . NotBeNull ( ) ;
266+ builder . ShouldNotBeNull ( ) ;
266267 var properties = builder . GetProperties ( ) ;
267- properties . Count . Should ( ) . Be ( 7 ) ;
268- properties [ "name" ] . Should ( ) . Be ( "this is a test" ) ;
269- properties [ "number" ] . Should ( ) . Be ( 123 ) ;
270- properties [ "decimal" ] . Should ( ) . Be ( 123.45 ) ;
271- properties [ "boolean" ] . Should ( ) . Be ( true ) ;
272- properties [ "null" ] . Should ( ) . BeNull ( ) ;
273- properties [ "array" ] . Should ( ) . BeOfType < object [ ] > ( ) ;
274- properties [ "array" ] . Should ( ) . BeEquivalentTo ( new List < string > { "this" , "is" , "a" , "test" } ) ;
275- properties [ "object" ] . Should ( ) . BeOfType < Dictionary < string , object > > ( ) ;
276- properties [ "object" ] . Should ( ) . BeEquivalentTo ( new Dictionary < string , object >
268+ properties . Count . ShouldBe ( 7 ) ;
269+ properties [ "name" ] . ShouldBe ( "this is a test" ) ;
270+ properties [ "number" ] . ShouldBe ( 123 ) ;
271+ properties [ "decimal" ] . ShouldBe ( 123.45 ) ;
272+ properties [ "boolean" ] . ShouldBe ( true ) ;
273+ properties [ "null" ] . ShouldBeNull ( ) ;
274+ properties [ "array" ] . ShouldBeOfType < object [ ] > ( ) ;
275+ properties [ "array" ] . ShouldBeEquivalentTo ( new object [ ] { "this" , "is" , "a" , "test" } ) ;
276+ properties [ "object" ] . ShouldBeEqualTo < Dictionary < string , object > > ( dict =>
277277 {
278- { "name" , "this is a test" } ,
279- { "number" , 123 } ,
280- { "decimal" , 123.45 } ,
281- { "boolean" , true } ,
282- { "null" , null ! } ,
283- { "array" , new List < string > { "this" , "is" , "a" , "test" } }
278+ dict . Count . ShouldBe ( 6 ) ;
279+ dict . ShouldContain ( "name" , "this is a test" ) ;
280+ dict . ShouldContain ( "number" , 123 ) ;
281+ dict . ShouldContain ( "decimal" , 123.45 ) ;
282+ dict . ShouldContain ( "boolean" , true ) ;
283+ dict . ShouldContain ( "null" , null ! ) ;
284+ dict . ShouldContain ( "array" , new object [ ] { "this" , "is" , "a" , "test" } ) ;
284285 } ) ;
285286 }
286287
@@ -308,29 +309,29 @@ public void LoadFrom_WithSpecificDataObjectFromString_Returns()
308309 }
309310 """ ) ;
310311
311- builder . Should ( ) . NotBeNull ( ) ;
312+ builder . ShouldNotBeNull ( ) ;
312313 var properties = builder . GetProperties ( ) ;
313- properties . Count . Should ( ) . Be ( 3 ) ;
314- properties [ "Title" ] . Should ( ) . Be ( "Section Page" ) ;
315- properties [ "Website" ] . Should ( ) . BeOfType < Dictionary < string , object > > ( ) ;
316- properties [ "Website" ] . Should ( ) . BeEquivalentTo ( new Dictionary < string , object >
314+ properties . Count . ShouldBe ( 3 ) ;
315+ properties [ "Title" ] . ShouldBe ( "Section Page" ) ;
316+ properties [ "Website" ] . ShouldBeOfType < Dictionary < string , object > > ( ) ;
317+ properties [ "Website" ] . ShouldBeEquivalentTo ( new Dictionary < string , object >
317318 {
318319 { "Author" , "htmlc" }
319320 } ) ;
320- properties [ "Names" ] . Should ( ) . BeOfType < object [ ] > ( ) ;
321+ properties [ "Names" ] . ShouldBeOfType < object [ ] > ( ) ;
321322 object [ ] objArray = ( properties [ "Names" ] as object [ ] ) ! ;
322- objArray [ 0 ] . Should ( ) . BeOfType < Dictionary < string , object > > ( ) ;
323- objArray [ 0 ] . Should ( ) . BeEquivalentTo ( new Dictionary < string , object >
323+ objArray [ 0 ] . ShouldBeOfType < Dictionary < string , object > > ( ) ;
324+ objArray [ 0 ] . ShouldBeEquivalentTo ( new Dictionary < string , object >
324325 {
325326 { "Name" , "Max" }
326327 } ) ;
327- objArray [ 1 ] . Should ( ) . BeOfType < Dictionary < string , object > > ( ) ;
328- objArray [ 1 ] . Should ( ) . BeEquivalentTo ( new Dictionary < string , object >
328+ objArray [ 1 ] . ShouldBeOfType < Dictionary < string , object > > ( ) ;
329+ objArray [ 1 ] . ShouldBeEquivalentTo ( new Dictionary < string , object >
329330 {
330331 { "Name" , "Lisa" }
331332 } ) ;
332- objArray [ 2 ] . Should ( ) . BeOfType < Dictionary < string , object > > ( ) ;
333- objArray [ 2 ] . Should ( ) . BeEquivalentTo ( new Dictionary < string , object >
333+ objArray [ 2 ] . ShouldBeOfType < Dictionary < string , object > > ( ) ;
334+ objArray [ 2 ] . ShouldBeEquivalentTo ( new Dictionary < string , object >
334335 {
335336 { "Name" , "Fred" }
336337 } ) ;
0 commit comments