Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 5f2012a

Browse files
committed
Update Clone/Open enabled tests
Add Open_Is_Enabled_When_Path_DirectoryExists test Fix/update some other tests
1 parent 43162db commit 5f2012a

File tree

1 file changed

+25
-9
lines changed

1 file changed

+25
-9
lines changed

test/GitHub.App.UnitTests/ViewModels/Dialog/Clone/RepositoryCloneViewModelTests.cs

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
using System;
22
using System.ComponentModel;
33
using System.IO;
4-
using System.Linq;
54
using System.Linq.Expressions;
6-
using System.Numerics;
5+
using System.Reactive.Linq;
76
using System.Threading.Tasks;
87
using GitHub.Extensions;
98
using GitHub.Models;
@@ -18,7 +17,8 @@ namespace GitHub.App.UnitTests.ViewModels.Dialog.Clone
1817
{
1918
public class RepositoryCloneViewModelTests
2019
{
21-
const string directoryExists = "d:\\exists";
20+
const string directoryExists = "d:\\exists\\directory";
21+
const string fileExists = "d:\\exists\\file";
2222
const string defaultPath = "d:\\default\\path";
2323

2424
[Test]
@@ -167,7 +167,7 @@ public async Task Owner_And_Repository_Name_Is_Appended_To_Base_Path()
167167
}
168168

169169
[Test]
170-
public async Task PathError_Is_Not_Set_When_No_Repository_Selected()
170+
public async Task PathWarning_Is_Not_Set_When_No_Repository_Selected()
171171
{
172172
var target = CreateTarget();
173173

@@ -177,11 +177,11 @@ public async Task PathError_Is_Not_Set_When_No_Repository_Selected()
177177
}
178178

179179
[Test]
180-
public async Task PathError_Is_Set_For_Existing_File_At_Destination()
180+
public async Task PathWarning_Is_Set_For_Existing_File_At_Destination()
181181
{
182182
var target = CreateTarget();
183183
SetRepository(target.GitHubTab, CreateRepositoryModel("owner", "repo"));
184-
target.Path = directoryExists;
184+
target.Path = fileExists;
185185

186186
Assert.That(target.PathWarning, Is.EqualTo(Resources.DestinationAlreadyExists));
187187
}
@@ -256,7 +256,7 @@ public async Task Clone_Is_Enabled_When_Repository_Selected()
256256
}
257257

258258
[Test]
259-
public async Task Clone_Is_Disabled_When_Has_PathError()
259+
public async Task Clone_Is_Disabled_When_Path_DirectoryExists()
260260
{
261261
var target = CreateTarget();
262262

@@ -270,6 +270,20 @@ public async Task Clone_Is_Disabled_When_Has_PathError()
270270
Assert.That(target.Clone.CanExecute(null), Is.False);
271271
}
272272

273+
[Test]
274+
public async Task Open_Is_Enabled_When_Path_DirectoryExists()
275+
{
276+
var target = CreateTarget();
277+
278+
await target.InitializeAsync(null);
279+
Assert.That(target.Open.CanExecute(null), Is.False);
280+
SetRepository(target.GitHubTab, CreateRepositoryModel());
281+
282+
target.Path = directoryExists;
283+
284+
Assert.That(target.Open.CanExecute(null), Is.True);
285+
}
286+
273287
static void SetRepository(IRepositoryCloneTabViewModel vm, IRepositoryModel repository)
274288
{
275289
vm.Repository.Returns(repository);
@@ -312,8 +326,10 @@ static IRepositoryCloneService CreateRepositoryCloneService(string defaultCloneP
312326
{
313327
var result = Substitute.For<IRepositoryCloneService>();
314328
result.DefaultClonePath.Returns(defaultClonePath);
315-
result.DestinationDirectoryExists(directoryExists).Returns(false);
316-
result.DestinationFileExists(directoryExists).Returns(true);
329+
result.DestinationDirectoryExists(directoryExists).Returns(true);
330+
result.DestinationFileExists(directoryExists).Returns(false);
331+
result.DestinationDirectoryExists(fileExists).Returns(false);
332+
result.DestinationFileExists(fileExists).Returns(true);
317333
return result;
318334
}
319335

0 commit comments

Comments
 (0)