コード例 #1
0
    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")));
        });
    }
コード例 #2
0
    public IGitRepository CreateAndCloneIfNeeded(string repoUrl, string repoPath, string branch)
    {
        if (!_staticWrapper.IsValid(repoPath))
        {
            DeleteAndCloneRepo(repoUrl, repoPath, branch);
        }

        return(_repoFactory(repoPath));
    }
コード例 #3
0
    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 !);