public async Task ListUpstreamMultiple()
        {
            using (var dir = new SelfDeletingDirectory(Path.GetFullPath(Path.Combine(basePath, nameof(this.ListUpstreamMultiple)))))
            {
                var upstreamPath   = Path.Combine(dir.Path, "Upstream");
                var authorPath     = Path.Combine(dir.Path, "Author");
                var downstreamPath = Path.Combine(dir.Path, "Downstream");
                var identity       = new Identity("Test Bot", "*****@*****.**");

                Repository.Init(upstreamPath, true);
                Repository.Clone(upstreamPath, authorPath);
                using (var repo = new Repository(authorPath))
                {
                    var testFilePath = Path.Combine(dir.Path, "Author/test.txt");
                    File.WriteAllText(testFilePath, "Some test data.");
                    Commands.Stage(repo, testFilePath);
                    var signature = new Signature(identity, DateTime.Now);
                    repo.Commit("Added test data", signature, signature);

                    //Sync main branch
                    var syncRepo = new SyncRepository(repo, mockup.Get <ICommitRepository>(), mockup.Get <IGitCredentialsProvider>(), mockup.Get <IProcessRunner>());
                    await syncRepo.Push();

                    var authorBranchRepo = new BranchRepository(repo, mockup.Get <ICommitRepository>());

                    //Create side branch
                    authorBranchRepo.Add("sidebranch");
                    authorBranchRepo.Checkout("sidebranch", new Signature(identity, DateTime.Now));
                    File.WriteAllText(testFilePath, "Some test data sidebranch.");
                    Commands.Stage(repo, testFilePath);
                    signature = new Signature(identity, DateTime.Now);
                    repo.Commit("Added test data", signature, signature);
                    await syncRepo.Push();

                    //Create another branch
                    authorBranchRepo.Add("another");
                    authorBranchRepo.Checkout("another", new Signature(identity, DateTime.Now));
                    File.WriteAllText(testFilePath, "Some test data another.");
                    Commands.Stage(repo, testFilePath);
                    signature = new Signature(identity, DateTime.Now);
                    repo.Commit("Added test data", signature, signature);
                    await syncRepo.Push();
                }

                Repository.Clone(upstreamPath, downstreamPath);
                using (var repo = new Repository(downstreamPath))
                {
                    var branchRepo = new BranchRepository(repo, mockup.Get <ICommitRepository>());
                    var branches   = branchRepo.List();
                    Assert.Equal(3, branches.Items.Count());
                }
            }
        }
        public async Task ListUpstreamOnlyMaster()
        {
            using (var dir = new SelfDeletingDirectory(Path.GetFullPath(Path.Combine(basePath, nameof(this.ListUpstreamOnlyMaster)))))
            {
                var upstreamPath   = Path.Combine(dir.Path, "Upstream");
                var authorPath     = Path.Combine(dir.Path, "Author");
                var downstreamPath = Path.Combine(dir.Path, "Downstream");

                Repository.Init(upstreamPath, true);
                Repository.Clone(upstreamPath, authorPath);
                using (var repo = new Repository(authorPath))
                {
                    var testFilePath = Path.Combine(dir.Path, "Author/test.txt");
                    File.WriteAllText(testFilePath, "Some test data.");
                    Commands.Stage(repo, testFilePath);
                    var signature = new Signature("Test Bot", "*****@*****.**", DateTime.Now);
                    repo.Commit("Added test data", signature, signature);

                    var syncRepo = new SyncRepository(repo, mockup.Get <ICommitRepository>(), mockup.Get <IGitCredentialsProvider>(), mockup.Get <IProcessRunner>());
                    await syncRepo.Push();
                }

                Repository.Clone(upstreamPath, downstreamPath);
                using (var repo = new Repository(downstreamPath))
                {
                    var branchRepo = new BranchRepository(repo, mockup.Get <ICommitRepository>());
                    var branches   = branchRepo.List();
                    Assert.Single(branches.Items);
                    Assert.Equal("master", branches.Items.First().FriendlyName);
                    Assert.Equal("refs/heads/master", branches.Items.First().CanonicalName);
                }
            }
        }
        public async Task UpstreamWithCheckout()
        {
            using (var dir = new SelfDeletingDirectory(Path.GetFullPath(Path.Combine(basePath, nameof(this.UpstreamWithCheckout)))))
            {
                var upstreamPath              = Path.Combine(dir.Path, "Upstream");
                var authorPath                = Path.Combine(dir.Path, "Author");
                var downstreamPath            = Path.Combine(dir.Path, "Downstream");
                var contents                  = "Main Branch";
                var sideContents              = "Side branch";
                var sideContentsRemoteChanges = "Side branch remote changes";
                var identity                  = new Identity("Test Bot", "*****@*****.**");

                Repository.Init(upstreamPath, true);
                Repository.Clone(upstreamPath, authorPath);
                using (var repo = new Repository(authorPath))
                {
                    var testFilePath = Path.Combine(dir.Path, "Author/test.txt");

                    //Create some test data on master
                    File.WriteAllText(testFilePath, contents);
                    Commands.Stage(repo, testFilePath);
                    var sig = new Signature(identity, DateTime.Now);
                    repo.Commit("Added test data", sig, sig);

                    //Switch to side branch, and make update
                    var authorBranchRepo = new BranchRepository(repo, mockup.Get <ICommitRepository>());
                    authorBranchRepo.Add("sidebranch");
                    authorBranchRepo.Checkout("sidebranch", new Signature(identity, DateTime.Now));
                    File.WriteAllText(testFilePath, sideContents);
                    Commands.Stage(repo, testFilePath);
                    sig = new Signature(identity, DateTime.Now);
                    repo.Commit("Updated branch data", sig, sig);
                    var syncRepo = new SyncRepository(repo, mockup.Get <ICommitRepository>(), mockup.Get <IGitCredentialsProvider>(), mockup.Get <IProcessRunner>());
                    //Push side branch
                    await syncRepo.Push();

                    //Back to master
                    authorBranchRepo.Checkout("master", new Signature(identity, DateTime.Now));
                    String masterText = File.ReadAllText(testFilePath);
                    Assert.Equal(contents, masterText);
                    await syncRepo.Push();
                }

                Repository.Clone(upstreamPath, downstreamPath);
                using (var repo = new Repository(downstreamPath))
                {
                    var testFilePath = Path.Combine(dir.Path, "Downstream/test.txt");
                    var branchRepo   = new BranchRepository(repo, mockup.Get <ICommitRepository>());

                    //First check master
                    String masterText = File.ReadAllText(testFilePath);
                    Assert.Equal(contents, masterText);

                    //Swith to side branch and check
                    branchRepo.Checkout("sidebranch", new Signature(identity, DateTime.Now));
                    String sideText = File.ReadAllText(testFilePath);
                    Assert.Equal(sideContents, sideText);

                    //Now make some changes and send them back
                    File.WriteAllText(testFilePath, sideContentsRemoteChanges);
                    Commands.Stage(repo, testFilePath);
                    var sig = new Signature(identity, DateTime.Now);
                    repo.Commit("Updated branch remotely", sig, sig);

                    var syncRepo = new SyncRepository(repo, mockup.Get <ICommitRepository>(), mockup.Get <IGitCredentialsProvider>(), mockup.Get <IProcessRunner>());
                    await syncRepo.Push();
                }

                using (var repo = new Repository(authorPath))
                {
                    var syncRepo = new SyncRepository(repo, mockup.Get <ICommitRepository>(), mockup.Get <IGitCredentialsProvider>(), mockup.Get <IProcessRunner>());
                    await syncRepo.Pull(new Signature(identity, DateTime.Now));

                    var testFilePath = Path.Combine(dir.Path, "Author/test.txt");
                    var branchRepo   = new BranchRepository(repo, mockup.Get <ICommitRepository>());
                    branchRepo.Checkout("sidebranch", new Signature(identity, DateTime.Now));

                    String text = File.ReadAllText(testFilePath);
                    Assert.Equal(sideContentsRemoteChanges, text);
                }
            }
        }