Пример #1
0
        protected override void Setup(bool usePrivateRepo)
        {
            // re-use test repo for Api tests
            this.source          = new ConfigSource();
            this.source.Hoster   = "bitbucket";
            this.source.Type     = "user";
            this.source.Name     = this.GetUserName(usePrivateRepo);
            this.source.AuthName = TestHelper.EnvVar(prefix, "Name");
            this.source.Password = TestHelper.EnvVar(prefix, "PW");

            var config = new Config();

            config.Sources.Add(this.source);

            var context = new FakeContext();

            context.Config = config;

            var api      = new BitbucketApi(new HttpRequest());
            var repoList = api.GetRepositoryList(this.source);

            this.repo = repoList.Find(r => r.ShortName == this.GetRepoName(usePrivateRepo));

            this.scm = new GitScm(new FileSystemHelper(), context);
            Assert.True(this.scm.IsOnThisComputer());

            var scmFactory = new FakeScmFactory();

            scmFactory.Register(ScmType.Git, this.scm);
            this.sut = new BitbucketBackup(scmFactory);
        }
Пример #2
0
        public GitlabApiTests()
        {
            var context = new FakeContext();
            var factory = new FakeScmFactory();

            factory.Register(ScmType.Git, new GitScm(new FileSystemHelper(), context));

            this.sut = new GitlabApi(new HttpRequest(), factory);
        }
Пример #3
0
        protected override void Setup(bool usePrivateRepo)
        {
            // re-use test repo for GithubApi tests
            this.source          = new ConfigSource();
            this.source.Hoster   = "github";
            this.source.Type     = "user";
            this.source.Name     = this.GetUserName(usePrivateRepo);
            this.source.AuthName = TestHelper.EnvVar("Github_Name");
            this.source.Password = TestHelper.EnvVar("Github_PW");

            var config = new Config();

            config.Sources.Add(this.source);

            var context = new FakeContext();

            context.Config = config;

            var factory = new FakeScmFactory();

            factory.Register(ScmType.Git, new GitScm(new FileSystemHelper(), context));

            var logger = new TestLogger("GithubBackupTests");

            logger.Log(ErrorLevel.Debug, "factory created");

            var api = new GithubApi(context, factory);

            this.repoList = api.GetRepositoryList(this.source);

            logger.Log(ErrorLevel.Debug, "API call finished");

            this.repo = this.repoList.Find(r => r.ShortName == this.GetRepoName(usePrivateRepo));

            this.scm = new GitScm(new FileSystemHelper(), context);
            Assert.True(this.scm.IsOnThisComputer());

            logger.Log(ErrorLevel.Debug, "Git found: {0}", this.scm.GetVersionNumber());

            var scmFactory = new FakeScmFactory();

            scmFactory.Register(ScmType.Git, this.scm);
            this.sut = new GithubBackup(scmFactory);

            logger.Log(ErrorLevel.Debug, "Setup finished");
        }