From 7d3e80e983ab3039bb6329cd6ddb8ead579ee3e8 Mon Sep 17 00:00:00 2001 From: Jamie Cansdale Date: Mon, 10 Sep 2018 09:38:05 +0100 Subject: [PATCH] Check owner is included in default repository path Expect test to fail until functionality implemented. --- .../Clone/RepositoryCloneViewModelTests.cs | 34 +++++++++++-------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/test/GitHub.App.UnitTests/ViewModels/Dialog/Clone/RepositoryCloneViewModelTests.cs b/test/GitHub.App.UnitTests/ViewModels/Dialog/Clone/RepositoryCloneViewModelTests.cs index 4e4eb5657..b9c976cdc 100644 --- a/test/GitHub.App.UnitTests/ViewModels/Dialog/Clone/RepositoryCloneViewModelTests.cs +++ b/test/GitHub.App.UnitTests/ViewModels/Dialog/Clone/RepositoryCloneViewModelTests.cs @@ -113,12 +113,10 @@ namespace GitHub.App.UnitTests.ViewModels.Dialog.Clone public async Task Repository_Name_Is_Appended_To_Base_Path() { var target = CreateTarget(); - var repository = Substitute.For(); - repository.Name.Returns("repo"); - SetRepository(target.GitHubTab, repository); + SetRepository(target.GitHubTab, CreateRepositoryModel("owner", "repo")); - Assert.That(target.Path, Is.EqualTo("d:\\efault\\path\\repo")); + Assert.That(target.Path, Is.EqualTo("d:\\efault\\path\\owner\\repo")); } [Test] @@ -135,10 +133,7 @@ namespace GitHub.App.UnitTests.ViewModels.Dialog.Clone public async Task PathError_Is_Set_For_Existing_Destination() { var target = CreateTarget(); - var repository = Substitute.For(); - - repository.Name.Returns("repo"); - SetRepository(target.GitHubTab, repository); + SetRepository(target.GitHubTab, CreateRepositoryModel("owner", "repo")); target.Path = "d:\\exists"; Assert.That(target.PathError, Is.EqualTo(Resources.DestinationAlreadyExists)); @@ -148,13 +143,14 @@ namespace GitHub.App.UnitTests.ViewModels.Dialog.Clone public async Task Repository_Name_Replaces_Last_Part_Of_Non_Base_Path() { var target = CreateTarget(); - var repository = Substitute.For(); - target.Path = "d:\\efault\\foo"; - repository.Name.Returns("repo"); - SetRepository(target.GitHubTab, repository); + var owner = "owner"; + target.Path = "d:\\efault"; + SetRepository(target.GitHubTab, CreateRepositoryModel(owner, "name")); + target.Path = $"d:\\efault\\{owner}\\foo"; + SetRepository(target.GitHubTab, CreateRepositoryModel(owner, "repo")); - Assert.That(target.Path, Is.EqualTo("d:\\efault\\repo")); + Assert.That(target.Path, Is.EqualTo($"d:\\efault\\{owner}\\repo")); } [Test] @@ -174,7 +170,7 @@ namespace GitHub.App.UnitTests.ViewModels.Dialog.Clone await target.InitializeAsync(null); - SetRepository(target.GitHubTab, Substitute.For()); + SetRepository(target.GitHubTab, CreateRepositoryModel()); Assert.That(target.Clone.CanExecute(null), Is.True); } @@ -186,7 +182,7 @@ namespace GitHub.App.UnitTests.ViewModels.Dialog.Clone await target.InitializeAsync(null); - SetRepository(target.GitHubTab, Substitute.For()); + SetRepository(target.GitHubTab, CreateRepositoryModel()); Assert.That(target.Clone.CanExecute(null), Is.True); target.Path = "d:\\exists"; @@ -260,5 +256,13 @@ namespace GitHub.App.UnitTests.ViewModels.Dialog.Clone enterpriseTab, urlTab); } + + static IRepositoryModel CreateRepositoryModel(string owner = "owner", string name = "repo") + { + var repository = Substitute.For(); + repository.Owner.Returns(owner); + repository.Name.Returns(name); + return repository; + } } }