Ejemplo n.º 1
0
        public void CreateBranchTest()
        {
            //Assert.Inconclusive("This test accesses file system.");

            var project = new Mock <VBProject>();
            var repo    = new Repository("SourceControlTest",
                                         Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "SourceControlTest"),
                                         @"https://github.com/ckuhn203/SourceControlTest.git"
                                         );
            var git = new GitProvider(project.Object);

            git = new GitProvider(project.Object, git.Clone(repo.RemoteLocation, repo.LocalLocation), new CodePaneWrapperFactory());

            git.CreateBranch("NewBranch");

            Assert.AreEqual("NewBranch", git.CurrentBranch);
        }
Ejemplo n.º 2
0
        public void CloneCreatesLocalRepo()
        {
            //Assert.Inconclusive("This test accesses file system.");

            //arrange
            var project  = new Mock <VBProject>();
            var expected = new Repository("SourceControlTest",
                                          Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "SourceControlTest"),
                                          @"https://github.com/ckuhn203/SourceControlTest.git"
                                          );
            var git = new GitProvider(project.Object);

            //act
            var actual = git.Clone(expected.RemoteLocation, expected.LocalLocation);

            //assert
            Assert.AreEqual(expected.Name, actual.Name);
            Assert.AreEqual(expected.LocalLocation, actual.LocalLocation);
            Assert.AreEqual(expected.RemoteLocation, actual.RemoteLocation);
            Assert.IsTrue(Directory.Exists(Path.Combine(expected.LocalLocation, ".git")));
        }
Ejemplo n.º 3
0
        public void CloneRepositoryTest()
        {
            var storageMock  = new Mock <RepositoryStorage>();
            var executorMock = new Mock <ScriptExecutor>();
            var gitMock      = new Mock <LibGit2SharpWrapper>();

            var provider = new GitProvider(storageMock.Object, executorMock.Object, gitMock.Object);

            Repository repository = new Repository();

            repository.Id  = "1";
            repository.Url = "fakeurl";
            var path = Path.Combine("/", repository.Id);

            storageMock.Setup(i => i.Combine(repository.Id)).Returns(path);
            gitMock.Setup(i => i.Clone(repository.Url, path)).Returns("");

            var result = provider.Clone(repository);

            Assert.Empty(result);
        }