public void Delete_and_clone_when_repo_is_not_valid( [Frozen] IRepositoryStaticWrapper wrapper, [Frozen] IFileUtilities fileUtils, GitRepositoryFactory sut) { wrapper.IsValid(Arg.Any <string>()).Returns(false); sut.CreateAndCloneIfNeeded("repo_url", "repo_path", "branch"); Received.InOrder(() => { wrapper.IsValid("repo_path"); fileUtils.DeleteReadOnlyDirectory("repo_path"); wrapper.Clone("repo_url", "repo_path", Verify.That <CloneOptions>(x => x.BranchName.Should().Be("branch"))); }); }
public IGitRepository CreateAndCloneIfNeeded(string repoUrl, string repoPath, string branch) { if (!_staticWrapper.IsValid(repoPath)) { DeleteAndCloneRepo(repoUrl, repoPath, branch); } return(_repoFactory(repoPath)); }
public void No_delete_and_clone_when_repo_is_valid( [Frozen] IRepositoryStaticWrapper wrapper, [Frozen] IFileUtilities fileUtils, GitRepositoryFactory sut) { wrapper.IsValid(Arg.Any <string>()).Returns(true); sut.CreateAndCloneIfNeeded("repo_url", "repo_path", "branch"); wrapper.Received().IsValid("repo_path"); fileUtils.DidNotReceiveWithAnyArgs().DeleteReadOnlyDirectory(default !);