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

Commit 43162db

Browse files
committed
Factor out magical strings
1 parent 27e13d2 commit 43162db

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

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

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.ComponentModel;
3+
using System.IO;
34
using System.Linq;
45
using System.Linq.Expressions;
56
using System.Numerics;
@@ -17,6 +18,9 @@ namespace GitHub.App.UnitTests.ViewModels.Dialog.Clone
1718
{
1819
public class RepositoryCloneViewModelTests
1920
{
21+
const string directoryExists = "d:\\exists";
22+
const string defaultPath = "d:\\default\\path";
23+
2024
[Test]
2125
public async Task GitHubPage_Is_Initialized()
2226
{
@@ -146,25 +150,28 @@ public async Task Path_Is_Initialized()
146150
{
147151
var target = CreateTarget();
148152

149-
Assert.That(target.Path, Is.EqualTo("d:\\efault\\path"));
153+
Assert.That(target.Path, Is.EqualTo(defaultPath));
150154
}
151155

152156
[Test]
153157
public async Task Owner_And_Repository_Name_Is_Appended_To_Base_Path()
154158
{
159+
var owner = "owner";
160+
var repo = "repo";
155161
var target = CreateTarget();
162+
var expectPath = Path.Combine(defaultPath, owner, repo);
156163

157-
SetRepository(target.GitHubTab, CreateRepositoryModel("owner", "repo"));
164+
SetRepository(target.GitHubTab, CreateRepositoryModel(owner, repo));
158165

159-
Assert.That(target.Path, Is.EqualTo("d:\\efault\\path\\owner\\repo"));
166+
Assert.That(target.Path, Is.EqualTo(expectPath));
160167
}
161168

162169
[Test]
163170
public async Task PathError_Is_Not_Set_When_No_Repository_Selected()
164171
{
165172
var target = CreateTarget();
166173

167-
target.Path = "d:\\exists";
174+
target.Path = directoryExists;
168175

169176
Assert.That(target.PathWarning, Is.Null);
170177
}
@@ -174,7 +181,7 @@ public async Task PathError_Is_Set_For_Existing_File_At_Destination()
174181
{
175182
var target = CreateTarget();
176183
SetRepository(target.GitHubTab, CreateRepositoryModel("owner", "repo"));
177-
target.Path = "d:\\exists";
184+
target.Path = directoryExists;
178185

179186
Assert.That(target.PathWarning, Is.EqualTo(Resources.DestinationAlreadyExists));
180187
}
@@ -258,7 +265,7 @@ public async Task Clone_Is_Disabled_When_Has_PathError()
258265
SetRepository(target.GitHubTab, CreateRepositoryModel());
259266
Assert.That(target.Clone.CanExecute(null), Is.True);
260267

261-
target.Path = "d:\\exists";
268+
target.Path = directoryExists;
262269

263270
Assert.That(target.Clone.CanExecute(null), Is.False);
264271
}
@@ -305,8 +312,8 @@ static IRepositoryCloneService CreateRepositoryCloneService(string defaultCloneP
305312
{
306313
var result = Substitute.For<IRepositoryCloneService>();
307314
result.DefaultClonePath.Returns(defaultClonePath);
308-
result.DestinationDirectoryExists("d:\\exists").Returns(false);
309-
result.DestinationFileExists("d:\\exists").Returns(true);
315+
result.DestinationDirectoryExists(directoryExists).Returns(false);
316+
result.DestinationFileExists(directoryExists).Returns(true);
310317
return result;
311318
}
312319

@@ -320,7 +327,7 @@ static RepositoryCloneViewModel CreateTarget(
320327
IRepositorySelectViewModel enterpriseTab = null,
321328
IGitService gitService = null,
322329
IRepositoryUrlViewModel urlTab = null,
323-
string defaultClonePath = "d:\\efault\\path")
330+
string defaultClonePath = defaultPath)
324331
{
325332
os = os ?? Substitute.For<IOperatingSystem>();
326333
connectionManager = connectionManager ?? CreateConnectionManager("https://github.com");

0 commit comments

Comments
 (0)