1- using Newtonsoft . Json ;
2- using Newtonsoft . Json . Linq ;
3- using System ;
1+ using System ;
42using System . Collections . Generic ;
53using System . Dynamic ;
64using System . Linq ;
75using System . Threading . Tasks ;
6+ using Newtonsoft . Json ;
7+ using Newtonsoft . Json . Linq ;
88using Xunit ;
99
1010namespace JsonFlatFileDataStore . Test
@@ -225,8 +225,8 @@ public async Task UpdateOneAsync_TypedModel_InnerSimpleArray()
225225 Type = "filled" ,
226226 Fragments = new List < string >
227227 {
228- Guid . NewGuid ( ) . ToString ( ) ,
229- Guid . NewGuid ( ) . ToString ( )
228+ Guid . NewGuid ( ) . ToString ( ) ,
229+ Guid . NewGuid ( ) . ToString ( )
230230 }
231231 } ;
232232
@@ -276,8 +276,8 @@ public async Task UpdateOneAsync_TypedModel_InnerSimpleIntArray()
276276 Type = "filled" ,
277277 Fragments = new List < int >
278278 {
279- 2 ,
280- 3
279+ 2 ,
280+ 3
281281 }
282282 } ;
283283
@@ -360,7 +360,8 @@ public async Task UpdateManyAsync_DynamicUser()
360360 var collection = store . GetCollection ( "user" ) ;
361361 Assert . Equal ( 3 , collection . Count ) ;
362362
363- var newUsers = new [ ] {
363+ var newUsers = new [ ]
364+ {
364365 new { id = 20 , name = "A1" , age = 55 } ,
365366 new { id = 21 , name = "A2" , age = 55 } ,
366367 new { id = 22 , name = "A3" , age = 55 }
@@ -500,7 +501,7 @@ public void ReplaceOne__Predicate_Id_TypedUser()
500501 var collection3 = store3 . GetCollection < User > ( "user" ) ;
501502 var updated = collection3 . Find ( e => e . Id == newUser . Id ) . First ( ) ;
502503 Assert . Equal ( "Theodor" , updated . Name ) ;
503-
504+
504505 collection3 . ReplaceOne ( newUser . Id , new User { Id = newUser . Id , Name = "Theodor_2" } ) ;
505506
506507 var store4 = new DataStore ( newFilePath ) ;
@@ -576,18 +577,20 @@ public void ReplaceOne_Upsert_DynamicWithInnerData()
576577
577578 var collection = store . GetCollection ( "sensor" ) ;
578579
579- var success = collection . ReplaceOne ( e => e . id == 11 , JToken . Parse ( "{ 'id': 11, 'mac': 'F4:A5:74:89:16:57', 'data': { 'temperature': 20.5 } }" ) , true ) ;
580+ var success = collection . ReplaceOne ( e => e . id == 11 ,
581+ JToken . Parse ( "{ 'id': 11, 'mac': 'F4:A5:74:89:16:57', 'data': { 'temperature': 20.5 } }" ) ,
582+ true ) ;
580583 Assert . True ( success ) ;
581584
582585 UTHelpers . Down ( newFilePath ) ;
583586 }
584-
587+
585588 [ Fact ]
586589 public async Task ReplaceOne_Upsert_Custom_Id_Dynamic ( )
587590 {
588591 var newFilePath = UTHelpers . Up ( ) ;
589592
590- var store = new DataStore ( newFilePath , keyProperty : "CustomId" ) ;
593+ var store = new DataStore ( newFilePath , keyProperty : "CustomId" ) ;
591594
592595 var collection = store . GetCollection ( "questions" ) ;
593596
@@ -596,23 +599,23 @@ public async Task ReplaceOne_Upsert_Custom_Id_Dynamic()
596599 CustomId = "54ccb8f2-5f2c-4cfa-b525-f0871eca787c" ,
597600 Name = "First_Tester"
598601 } ;
599-
602+
600603 var itemTwo = new
601604 {
602605 CustomId = "ee314079-7d18-405b-9bb7-9248c672b3f5" ,
603606 Name = "Second_Tester"
604607 } ;
605-
608+
606609 var success = await collection . ReplaceOneAsync ( item . CustomId , item , true ) ;
607610 Assert . True ( success ) ;
608-
611+
609612 success = await collection . ReplaceOneAsync ( itemTwo . CustomId , itemTwo , true ) ;
610613 Assert . True ( success ) ;
611-
614+
612615 var fromDb = collection . AsQueryable ( ) . SingleOrDefault ( e => e . CustomId == itemTwo . CustomId ) ;
613616 Assert . NotNull ( fromDb ) ;
614617 Assert . Equal ( "Second_Tester" , fromDb . Name ) ;
615-
618+
616619 UTHelpers . Down ( newFilePath ) ;
617620 }
618621
@@ -864,8 +867,8 @@ public void UpdateOne_InnerCollection_FromAndToNull_Typed()
864867 var collection = store . GetCollection < Family > ( ) ;
865868
866869 var family = collection
867- . Find ( p => p . Id == 4 )
868- . First ( ) ;
870+ . Find ( p => p . Id == 4 )
871+ . First ( ) ;
869872
870873 Assert . Null ( family . Children [ 1 ] . Friends ) ;
871874
@@ -881,8 +884,8 @@ public void UpdateOne_InnerCollection_FromAndToNull_Typed()
881884 var collection2 = store2 . GetCollection < Family > ( ) ;
882885
883886 var family_updated = collection2
884- . Find ( p => p . Id == 4 )
885- . First ( ) ;
887+ . Find ( p => p . Id == 4 )
888+ . First ( ) ;
886889
887890 Assert . Equal ( originalCount , family_updated . Children [ 1 ] . Friends . Count ) ;
888891 Assert . Null ( family_updated . Children [ 0 ] . Friends ) ;
@@ -900,8 +903,8 @@ public void UpdateOne_InnerCollection_FromAndToNull_Dynamic()
900903 var collection = store . GetCollection ( "family" ) ;
901904
902905 var family = collection
903- . Find ( p => p . id == 4 )
904- . First ( ) ;
906+ . Find ( p => p . id == 4 )
907+ . First ( ) ;
905908
906909 Assert . Null ( family . children [ 1 ] . friends ) ;
907910
@@ -917,15 +920,15 @@ public void UpdateOne_InnerCollection_FromAndToNull_Dynamic()
917920 var collection2 = store2 . GetCollection < Family > ( ) ;
918921
919922 var family_updated = collection2
920- . Find ( p => p . Id == 4 )
921- . First ( ) ;
923+ . Find ( p => p . Id == 4 )
924+ . First ( ) ;
922925
923926 Assert . Equal ( origCount , family_updated . Children [ 1 ] . Friends . Count ) ;
924927 Assert . Null ( family_updated . Children [ 0 ] . Friends ) ;
925928
926929 UTHelpers . Down ( newFilePath ) ;
927930 }
928-
931+
929932 [ Fact ]
930933 public async Task UpdateInnerFloatArray_DynamicWorld ( )
931934 {
@@ -936,19 +939,19 @@ public async Task UpdateInnerFloatArray_DynamicWorld()
936939 var collection = store . GetCollection ( "worlds" ) ;
937940 Assert . Equal ( 1 , collection . Count ) ;
938941
939- var original = collection . Find ( e=> e . id == 0 ) . First ( ) ;
942+ var original = collection . Find ( e => e . id == 0 ) . First ( ) ;
940943 Assert . Equal ( 3.6640577 , original . position [ 0 ] ) ;
941944
942945 await collection . UpdateOneAsync ( e => e . id == 0 , new { cameraRotationX = 5.2 } ) ;
943-
946+
944947 var collection2 = store . GetCollection ( "worlds" ) ;
945- var updated = collection2 . Find ( e=> e . id == 0 ) . First ( ) ;
948+ var updated = collection2 . Find ( e => e . id == 0 ) . First ( ) ;
946949 Assert . Equal ( 5.2 , updated . cameraRotationX ) ;
947-
948- await collection . UpdateOneAsync ( e => e . id == 0 , new { position = new float [ ] { 10 , 11 , 12 } } ) ;
949-
950+
951+ await collection . UpdateOneAsync ( e => e . id == 0 , new { position = new float [ ] { 10 , 11 , 12 } } ) ;
952+
950953 var collection3 = store . GetCollection ( "worlds" ) ;
951- var updated2 = collection3 . Find ( e=> e . id == 0 ) . First ( ) ;
954+ var updated2 = collection3 . Find ( e => e . id == 0 ) . First ( ) ;
952955 Assert . Equal ( 10 , updated2 . position [ 0 ] ) ;
953956 Assert . Equal ( 11 , updated2 . position [ 1 ] ) ;
954957 Assert . Equal ( 12 , updated2 . position [ 2 ] ) ;
@@ -969,13 +972,13 @@ public async Task UpdateInnerFloatArray_TypedWorld()
969972 var original = collection . Find ( e => e . Id == 0 ) . First ( ) ;
970973 Assert . InRange ( original . Position [ 0 ] , 3.66 , 3.67 ) ;
971974
972- await collection . UpdateOneAsync ( e => e . Id == 0 , new { CameraRotationX = 5.2f } ) ;
975+ await collection . UpdateOneAsync ( e => e . Id == 0 , new { CameraRotationX = 5.2f } ) ;
973976
974977 var collection2 = store . GetCollection < World > ( "worlds" ) ;
975978 var updated = collection2 . Find ( e => e . Id == 0 ) . First ( ) ;
976979 Assert . InRange ( updated . CameraRotationX , 5.19 , 5.2 ) ;
977980
978- await collection . UpdateOneAsync ( e => e . Id == 0 , new { Position = new float [ ] { 10 , 11 , 12 } } ) ;
981+ await collection . UpdateOneAsync ( e => e . Id == 0 , new { Position = new float [ ] { 10 , 11 , 12 } } ) ;
979982
980983 var collection3 = store . GetCollection < World > ( "worlds" ) ;
981984 var updated2 = collection3 . Find ( e => e . Id == 0 ) . First ( ) ;
0 commit comments