@@ -96,7 +96,7 @@ public void Copy_directory_copies_all_supported_files()
96
96
97
97
var filesCount = FilesWithMetadata . Count ( ) ;
98
98
output . Should ( ) . EndWith (
99
- $ "Found { filesCount } camera files . Processed { filesCount } . Skipped 0. Transferred { filesCount } .\n ") ;
99
+ $ "Found { filesCount } camera file(s) . Processed { filesCount } . Skipped 0. Transferred { filesCount } .\n ") ;
100
100
101
101
102
102
void VerifyDirectoryCreatedAndFileCopied (
@@ -146,7 +146,7 @@ public void Move_directory_copies_all_supported_files()
146
146
147
147
var filesCount = FilesWithMetadata . Count ( ) ;
148
148
output . Should ( ) . EndWith (
149
- $ "Found { filesCount } camera files . Processed { filesCount } . Skipped 0. Transferred { filesCount } .\n ") ;
149
+ $ "Found { filesCount } camera file(s) . Processed { filesCount } . Skipped 0. Transferred { filesCount } .\n ") ;
150
150
151
151
152
152
void VerifyDirectoryCreatedAndFileCopied (
@@ -210,7 +210,59 @@ public void Copy_directory_skips_files_which_already_exist_in_the_destination()
210
210
output . Should ( ) . EndWith (
211
211
"Skipped 1 file(s) because they already exist at the destination.\n " +
212
212
$ "{ fileWithMetadata . sourceFile } exists as { fileWithMetadata . expectedDestinationFile } \n \n " +
213
- "Found 1 camera files. Processed 1. Skipped 1. Transferred 0.\n " ) ;
213
+ "Found 1 camera file(s). Processed 1. Skipped 1. Transferred 0.\n " ) ;
214
+ }
215
+
216
+ [ Fact ]
217
+ public void Copy_overwrites_files_which_already_exist_in_the_destination_in_overwrite_mode ( )
218
+ {
219
+ /* Arrange */
220
+ var fileWithMetadata =
221
+ (
222
+ sourceFile : $ "{ SourceDirPath } /IMG_1234.JPG",
223
+ exifTags : NewImageFileTags ( "2010:01:12 13:14:15" , "42" ) ,
224
+ expectedDestinationDirectory : $ "{ DestinationDirPath } /2010_01_12",
225
+ expectedDestinationFile : $ "{ DestinationDirPath } /2010_01_12/IMG_20100112_131415420.JPG") ;
226
+ var fixture = new Fixture ( ) . Customize ( new AutoMoqCustomization ( ) ) ;
227
+ var fileSystemMock =
228
+ fixture
229
+ . Freeze < Mock < IFileSystem > > ( )
230
+ . SetupDefaults ( )
231
+ . SetupSourceDirectoryWithFiles ( SourceDirPath , new [ ] { fileWithMetadata . sourceFile } ) ;
232
+ fileSystemMock
233
+ . Setup ( fs => fs . Directory . Exists ( fileWithMetadata . expectedDestinationDirectory ) )
234
+ . Returns ( true ) ;
235
+ fileSystemMock
236
+ . Setup ( fs => fs . File . Exists ( fileWithMetadata . expectedDestinationFile ) )
237
+ . Returns ( true ) ;
238
+ fixture
239
+ . Freeze < Mock < IMetadataReader > > ( )
240
+ . SetupMetadata ( new [ ] { ( fileWithMetadata . sourceFile , fileWithMetadata . exifTags ) } ) ;
241
+ var consoleTextWriterMock = new StringWriter ( ) ;
242
+ fixture . Inject < TextWriter > ( consoleTextWriterMock ) ;
243
+ var sut = fixture . Create < Program > ( ) ;
244
+
245
+ /* Act */
246
+ var result = sut . Execute ( $ "copy { SourceDirPath } { DestinationDirPath } --overwrite". Split ( ) ) ;
247
+
248
+ /* Assert */
249
+ result . Should ( ) . Be ( 0 ) ;
250
+ var output = consoleTextWriterMock . ToString ( ) ;
251
+ var ( file , _, _, expectedDestinationFile ) = fileWithMetadata ;
252
+ VerifyDirectoryCreatedAndFileCopied ( file , expectedDestinationFile ) ;
253
+ output . Should ( ) . Contain ( $ "{ file } -> { expectedDestinationFile } ") ;
254
+ output . Should ( ) . EndWith ( "Found 1 camera file(s). Processed 1. Skipped 0. Transferred 1.\n " ) ;
255
+
256
+ void VerifyDirectoryCreatedAndFileCopied (
257
+ string sourceFile ,
258
+ string destinationFile )
259
+ {
260
+ fileSystemMock . Verify ( fs =>
261
+ fs . File . Copy (
262
+ sourceFile ,
263
+ destinationFile ,
264
+ true ) ) ;
265
+ }
214
266
}
215
267
216
268
[ Fact ]
@@ -277,7 +329,7 @@ public void Files_are_not_transferred_in_dry_run_mode(
277
329
278
330
var filesCount = FilesWithMetadata . Count ( ) ;
279
331
output . Should ( ) . EndWith (
280
- $ "Found { filesCount } camera files . Processed { filesCount } . Skipped 0. Transferred 0.\n ") ;
332
+ $ "Found { filesCount } camera file(s) . Processed { filesCount } . Skipped 0. Transferred 0.\n ") ;
281
333
}
282
334
283
335
[ Fact ]
@@ -312,7 +364,7 @@ public void First_error_stops_execution()
312
364
var output = consoleTextWriterMock . ToString ( ) ;
313
365
output . Should ( ) . Be (
314
366
$ "Failed { SourceDirPath } /IMG_1234.JPG: PROCESSING EXCEPTION\n \n " +
315
- "Found 2 camera files . Processed 1. Skipped 0. Transferred 0.\n " ) ;
367
+ "Found 2 camera file(s) . Processed 1. Skipped 0. Transferred 0.\n " ) ;
316
368
fileSystemMock . Verify ( fs =>
317
369
fs . File . Copy ( It . IsAny < string > ( ) , It . IsAny < string > ( ) , It . IsAny < bool > ( ) ) ,
318
370
Times . Never ) ;
@@ -368,7 +420,7 @@ public void Errors_do_not_stop_execution_in_keep_going_mode()
368
420
"Following errors occurred:\n " +
369
421
$ "{ SourceDirPath } /IMG_1234.JPG: PROCESSING EXCEPTION\n " +
370
422
$ "{ SourceDirPath } /IMG_2345.jpg: Metadata not found\n \n " +
371
- "Found 3 camera files . Processed 3. Skipped 0. Transferred 1.\n " ) ;
423
+ "Found 3 camera file(s) . Processed 3. Skipped 0. Transferred 1.\n " ) ;
372
424
fileSystemMock . Verify ( fs =>
373
425
fs . File . Copy ( $ "{ SourceDirPath } /IMG_1234.JPG", It . IsAny < string > ( ) , It . IsAny < bool > ( ) ) ,
374
426
Times . Never ) ;
@@ -426,7 +478,7 @@ public void Cancellation_stops_execution_and_prints_summary()
426
478
$ "{ SourceDirPath } /IMG_1234.JPG -> { DestinationDirPath } /2010_01_12/IMG_20100112_131415420.JPG\n " +
427
479
$ "Created { DestinationDirPath } /2011_02_13\n " +
428
480
$ "{ SourceDirPath } /IMG_4231.JPEG -> { DestinationDirPath } /2011_02_13/IMG_20110213_141516430.JPEG\n \n " +
429
- "Found 3 camera files . Processed 2. Skipped 0. Transferred 2.\n " +
481
+ "Found 3 camera file(s) . Processed 2. Skipped 0. Transferred 2.\n " +
430
482
"Operation interrupted by user.\n " ) ;
431
483
fileSystemMock . Verify ( fs =>
432
484
fs . File . Copy (
@@ -499,7 +551,7 @@ public void Copy_directory_copies_all_supported_files()
499
551
500
552
var filesCount = FilesWithMetadata . Count ( ) ;
501
553
output . Should ( ) . EndWith (
502
- $ "Found { filesCount } camera files . Processed { filesCount } . Skipped 0. Transferred { filesCount } .\n ") ;
554
+ $ "Found { filesCount } camera file(s) . Processed { filesCount } . Skipped 0. Transferred { filesCount } .\n ") ;
503
555
504
556
505
557
void VerifyDirectoryCreatedAndFileCopied (
0 commit comments