@@ -46,7 +46,7 @@ public async Task RNFSManager_writeFile()
4646 var hello = "Hello World" ;
4747 var base64Content = Convert . ToBase64String ( Encoding . UTF8 . GetBytes ( hello ) ) ;
4848 var promise = new MockPromise ( ) ;
49- manager . writeFile ( path , base64Content , promise ) ;
49+ manager . writeFile ( path , base64Content , new JObject ( ) , promise ) ;
5050 await promise . Task ;
5151
5252 // Assert
@@ -73,7 +73,7 @@ public async Task RNFSManager_writeFile_ExistingFile()
7373 var hello = "Hello World" ;
7474 var base64Content = Convert . ToBase64String ( Encoding . UTF8 . GetBytes ( hello ) ) ;
7575 var promise = new MockPromise ( ) ;
76- manager . writeFile ( path , base64Content , promise ) ;
76+ manager . writeFile ( path , base64Content , new JObject ( ) , promise ) ;
7777 await promise . Task ;
7878
7979 // Assert
@@ -100,8 +100,8 @@ public async Task RNFSManager_writeFile_ExistingDirectory()
100100 var hello = "Hello World" ;
101101 var base64Content = Convert . ToBase64String ( Encoding . UTF8 . GetBytes ( hello ) ) ;
102102 var promise = new MockPromise ( ) ;
103- manager . writeFile ( path , base64Content , promise ) ;
104- await AssertRejectAsync ( promise , ex => Assert . IsTrue ( ex . InnerException is UnauthorizedAccessException ) ) ;
103+ manager . writeFile ( path , base64Content , new JObject ( ) , promise ) ;
104+ await AssertRejectAsync ( promise , ex => Assert . AreEqual ( ex . Message , $ "Access to the path ' { path } ' is denied." , $ "Message was { ex . Message } " ) ) ;
105105
106106 // Cleanup
107107 Directory . Delete ( path ) ;
@@ -116,11 +116,12 @@ public async Task RNFSManager_writeFile_Fail()
116116
117117 // Run test
118118 var promise = new MockPromise ( ) ;
119- manager . writeFile ( "badPath" , "" , promise ) ;
119+ var path = $ "{ Windows . ApplicationModel . Package . Current . InstalledLocation . Path } \\ badPath";
120+ manager . writeFile ( path , "" , new JObject ( ) , promise ) ;
120121
121122 await AssertRejectAsync (
122123 promise ,
123- ex => Assert . IsTrue ( ex . InnerException is UnauthorizedAccessException ) ) ;
124+ ex => Assert . AreEqual ( ex . Message , $ "Access to the path ' { path } ' is denied." , $ "Message was { ex . Message } " ) ) ;
124125 }
125126
126127 [ TestMethod ]
@@ -218,7 +219,7 @@ public async Task RNFSManager_write_ExistingDirectory()
218219 var base64Content = Convert . ToBase64String ( Encoding . UTF8 . GetBytes ( hello ) ) ;
219220 var promise = new MockPromise ( ) ;
220221 manager . write ( path , base64Content , 0 , promise ) ;
221- await AssertRejectAsync ( promise , ex => Assert . IsTrue ( ex . InnerException is UnauthorizedAccessException ) ) ;
222+ await AssertRejectAsync ( promise , ex => Assert . AreEqual ( ex . Message , $ "Access to the path ' { path } ' is denied." , $ "Message was { ex . Message } " ) ) ;
222223
223224 // Cleanup
224225 Directory . Delete ( path ) ;
@@ -287,10 +288,11 @@ public async Task RNFSManager_write_Fail()
287288
288289 // Run test
289290 var promise = new MockPromise ( ) ;
290- manager . write ( "badPath" , "" , 0 , promise ) ;
291+ var path = $ "{ Windows . ApplicationModel . Package . Current . InstalledLocation . Path } \\ badPath";
292+ manager . write ( path , "" , 0 , promise ) ;
291293 await AssertRejectAsync (
292294 promise ,
293- ex => Assert . IsTrue ( ex . InnerException is UnauthorizedAccessException ) ) ;
295+ ex => Assert . AreEqual ( ex . Message , $ "Access to the path ' { path } ' is denied." , $ "Message was { ex . Message } " ) ) ;
294296 }
295297
296298 [ TestMethod ]
@@ -648,7 +650,7 @@ public async Task RNFSManager_moveFile()
648650 // Run test
649651 var newPath = Path . Combine ( tempFolder , Guid . NewGuid ( ) . ToString ( ) ) ;
650652 var promise = new MockPromise ( ) ;
651- manager . moveFile ( path , newPath , promise ) ;
653+ manager . moveFile ( path , newPath , new JObject ( ) , promise ) ;
652654 await promise . Task ;
653655
654656 // Assert
@@ -672,7 +674,7 @@ public async Task RNFSManager_moveFile_NotExists()
672674 var path = Path . Combine ( tempFolder , Guid . NewGuid ( ) . ToString ( ) ) ;
673675 var newPath = Path . Combine ( tempFolder , Guid . NewGuid ( ) . ToString ( ) ) ;
674676 var promise = new MockPromise ( ) ;
675- manager . moveFile ( path , newPath , promise ) ;
677+ manager . moveFile ( path , newPath , new JObject ( ) , promise ) ;
676678 await AssertRejectAsync ( promise , ex => Assert . AreEqual ( "ENOENT" , ex . Code ) ) ;
677679 }
678680
@@ -692,7 +694,7 @@ public async Task RNFSManager_copyFile()
692694 // Run test
693695 var newPath = Path . Combine ( tempFolder , Guid . NewGuid ( ) . ToString ( ) ) ;
694696 var promise = new MockPromise ( ) ;
695- manager . copyFile ( path , newPath , promise ) ;
697+ manager . copyFile ( path , newPath , new JObject ( ) , promise ) ;
696698 await promise . Task ;
697699
698700 // Assert
@@ -717,7 +719,7 @@ public async Task RNFSManager_copyFile_NotExists()
717719 var path = Path . Combine ( tempFolder , Guid . NewGuid ( ) . ToString ( ) ) ;
718720 var newPath = Path . Combine ( tempFolder , Guid . NewGuid ( ) . ToString ( ) ) ;
719721 var promise = new MockPromise ( ) ;
720- manager . copyFile ( path , newPath , promise ) ;
722+ manager . copyFile ( path , newPath , new JObject ( ) , promise ) ;
721723 await AssertRejectAsync ( promise , ex => Assert . AreEqual ( "ENOENT" , ex . Code ) ) ;
722724 }
723725
@@ -1066,7 +1068,7 @@ public async Task RNFSManager_mkdir_ExistingFile()
10661068 // Run test
10671069 var promise = new MockPromise ( ) ;
10681070 manager . mkdir ( path , null , promise ) ;
1069- await AssertRejectAsync ( promise , ex => Assert . IsTrue ( ex . InnerException is IOException ) ) ;
1071+ await AssertRejectAsync ( promise , ex => Assert . AreEqual ( ex . Message , $ "Cannot create ' { path } ' because a file or directory with the same name already exists." , $ "Message was { ex . Message } " ) ) ;
10701072
10711073 // Cleanup
10721074 File . Delete ( path ) ;
@@ -1105,11 +1107,12 @@ public async Task RNFSManager_mkdir_Fail()
11051107
11061108 // Run test
11071109 var promise = new MockPromise ( ) ;
1108- manager . mkdir ( "badPath" , null , promise ) ;
1110+ var path = $ "{ Windows . ApplicationModel . Package . Current . InstalledLocation . Path } \\ badPath";
1111+ manager . mkdir ( path , null , promise ) ;
11091112
11101113 await AssertRejectAsync (
11111114 promise ,
1112- ex => Assert . IsTrue ( ex . InnerException is UnauthorizedAccessException ) ) ;
1115+ ex => Assert . AreEqual ( $ "Access to the path ' { path } ' is denied." , ex . Message , $ "Message was { ex . Message } " ) ) ;
11131116 }
11141117
11151118 [ TestMethod ]
@@ -1213,7 +1216,7 @@ public async Task RNFSManager_touch_ExistingDirectory()
12131216 ConvertToUnixTimestamp ( mtime ) ,
12141217 ConvertToUnixTimestamp ( ctime ) ,
12151218 promise ) ;
1216- await AssertRejectAsync ( promise , ex => Assert . IsTrue ( ex . InnerException is UnauthorizedAccessException ) ) ;
1219+ await AssertRejectAsync ( promise , ex => Assert . AreEqual ( ex . Message , $ "Access to the path ' { path } ' is denied." , $ "Message was { ex . Message } " ) ) ;
12171220
12181221 // Cleanup
12191222 Directory . Delete ( path ) ;
@@ -1402,7 +1405,7 @@ public async Task RNFSManager_downloadFile_ExistingDirectory()
14021405
14031406 var promise = new MockPromise ( ) ;
14041407 manager . downloadFile ( options , promise ) ;
1405- await AssertRejectAsync ( promise , ex => Assert . IsTrue ( ex . InnerException is UnauthorizedAccessException ) ) ;
1408+ await AssertRejectAsync ( promise , ex => Assert . AreEqual ( ex . Message , $ "Access to the path ' { path } ' is denied." , $ "Message was { ex . Message } " ) ) ;
14061409
14071410 // Cleanup
14081411 Directory . Delete ( path ) ;
@@ -1470,7 +1473,7 @@ public async Task RNFSManager_stopDownload()
14701473 var promise = new MockPromise ( ) ;
14711474 manager . downloadFile ( options , promise ) ;
14721475 manager . stopDownload ( 1 ) ;
1473- await AssertRejectAsync ( promise , ex => Assert . IsTrue ( ex . InnerException is TaskCanceledException ) ) ;
1476+ await AssertRejectAsync ( promise , ex => Assert . AreEqual ( "A task was canceled." , ex . Message , ex . Message ) ) ;
14741477 Assert . IsFalse ( new FileInfo ( path ) . Exists ) ;
14751478 }
14761479
@@ -1592,11 +1595,16 @@ public void Reject(Exception exception)
15921595 _tcs . SetException ( new RejectException ( null , null , exception ) ) ;
15931596 }
15941597
1598+ public void Reject ( string code , string message , string stack , JToken userInfo )
1599+ {
1600+ _tcs . SetException ( new RejectException ( code , message ) ) ;
1601+ }
1602+
15951603 public void Resolve ( object value )
15961604 {
1597- _tcs . SetResult ( value ) ;
1605+ _tcs . SetResult ( value ) ;
15981606 }
1599- }
1607+ }
16001608
16011609 class RejectException : Exception
16021610 {
0 commit comments