@@ -17,6 +17,7 @@ namespace GitHub.App.UnitTests.ViewModels.Dialog.Clone
1717{
1818 public class RepositoryCloneViewModelTests
1919 {
20+ const string directoryEmpty = "d:\\ empty\\ directory" ;
2021 const string directoryExists = "d:\\ exists\\ directory" ;
2122 const string fileExists = "d:\\ exists\\ file" ;
2223 const string defaultPath = "d:\\ default\\ path" ;
@@ -244,6 +245,16 @@ public void PathWarning_Is_Set_For_Existing_Repository_At_Destination_With_Diffe
244245 Assert . That ( target . PathWarning , Is . EqualTo ( expectMessage ) ) ;
245246 }
246247
248+ [ Test ]
249+ public void PathWarning_Is_Not_Set_When_EmptyDirectoryExists_Selected ( )
250+ {
251+ var target = CreateTarget ( ) ;
252+
253+ target . Path = directoryEmpty ;
254+
255+ Assert . That ( target . PathWarning , Is . Null ) ;
256+ }
257+
247258 [ Test ]
248259 public void Repository_Name_Replaces_Last_Part_Of_Non_Base_Path ( )
249260 {
@@ -342,6 +353,21 @@ public async Task Open_Is_Enabled_When_Path_DirectoryExists()
342353 Assert . That ( target . Open . CanExecute ( null ) , Is . True ) ;
343354 }
344355
356+ [ Test ]
357+ public async Task Clone_Is_Enabled_When_Path_EmptyDirectoryExists ( )
358+ {
359+ var target = CreateTarget ( ) ;
360+
361+ await target . InitializeAsync ( null ) ;
362+
363+ SetRepository ( target . GitHubTab , CreateRepositoryModel ( ) ) ;
364+ Assert . That ( target . Clone . CanExecute ( null ) , Is . True ) ;
365+
366+ target . Path = directoryEmpty ;
367+
368+ Assert . That ( target . Clone . CanExecute ( null ) , Is . True ) ;
369+ }
370+
345371 static void SetRepository ( IRepositoryCloneTabViewModel vm , RepositoryModel repository )
346372 {
347373 vm . Repository . Returns ( repository ) ;
@@ -385,6 +411,8 @@ static IRepositoryCloneService CreateRepositoryCloneService(string defaultCloneP
385411 var result = Substitute . For < IRepositoryCloneService > ( ) ;
386412 result . DefaultClonePath . Returns ( defaultClonePath ) ;
387413 result . DestinationDirectoryExists ( directoryExists ) . Returns ( true ) ;
414+ result . DestinationDirectoryExists ( directoryEmpty ) . Returns ( true ) ;
415+ result . DestinationDirectoryEmpty ( directoryEmpty ) . Returns ( true ) ;
388416 result . DestinationFileExists ( directoryExists ) . Returns ( false ) ;
389417 result . DestinationDirectoryExists ( fileExists ) . Returns ( false ) ;
390418 result . DestinationFileExists ( fileExists ) . Returns ( true ) ;
0 commit comments