コード例 #1
0
ファイル: IGitDb.cs プロジェクト: c-mueller/Appy.GitDb
        public static async Task GetFiles <T>(this IGitDb gitDb, string branch, string key, int pageSize, Func <IReadOnlyCollection <T>, Task> processPage)
        {
            PagedFiles <T> currentResult = null;

            do
            {
                currentResult = await gitDb.GetFilesPaged <T>(branch, key, currentResult?.End ?? 0, pageSize);
                await processPage(currentResult.Files);
            } while (currentResult.Total > currentResult.End);
        }
コード例 #2
0
        public async Task InitializeAsync()
        {
            const string url = "http://localhost"; // this is a dummy url, requests are in-memory, not over the network
            var          app = App.Create(url, new LocalGitDb(LocalPath, new AutoMocker().Get <ILogger>()), new AutoMocker().Get <ILogger>(), _users);

            _server = TestServer.Create(app.Configuration);
            _client = _server.HttpClient;
            WithUser(Admin);
            Subject = new RemoteGitDb(_client, url);
            Repo    = new Repository(LocalPath);
            await Because();
        }
コード例 #3
0
        public async Task InitializeAsync()
        {
            GitDb = new LocalGitDb(LocalPath, new AutoMocker().Get <ILogger>());
            Repo  = new Repository(LocalPath);
            await Setup();

            Subject = new GitDb.Watcher.Watcher(LocalPath, new AutoMocker().Get <ILogger>(), 1);
            Subject.MonitorEvents();
            Subject.Start(new List <BranchInfo>());
            await Because();

            Thread.Sleep(150);
        }
コード例 #4
0
        public static App Create(string url, IGitDb repo, ILogger serverLog, IEnumerable <User> users)
        {
            var builder = new ContainerBuilder();

            builder.RegisterInstance(repo).As <IGitDb>().ExternallyOwned();
            builder.RegisterApiControllers(typeof(App).Assembly);

            var app = new App
            {
                _container = builder.Build(),
                _url       = url,
                _users     = users,
                _serverLog = serverLog
            };

            return(app);
        }
コード例 #5
0
        public async Task InitializeAsync()
        {
            GitDb = new LocalGitDb(_localPath);
            Repo  = new Repository(_localPath);
            await Task.WhenAll(Enumerable.Range(0, 20)
                               .Select(i => GitDb.Save("master", $"Commit {i}", new Document {
                Key = $"{i}.json", Value = i.ToString()
            }, Author)));

            await Setup();

            Subject = new GitDb.Watcher.Watcher(_localPath, 1, addToList(BranchAdded), addToList(BranchChanged), addToList(BranchRemoved));

            await Subject.Start(new List <BranchInfo>());

            await Because();

            Thread.Sleep(500);
        }
コード例 #6
0
 public GitApiController(IGitDb gitDb)
 {
     _gitDb = gitDb;
 }
コード例 #7
0
ファイル: IGitDb.cs プロジェクト: c-mueller/Appy.GitDb
 public static Task GetFiles <T>(this IGitDb gitDb, string branch, string key, int pageSize, Action <IReadOnlyCollection <T> > processPage) =>
 gitDb.GetFiles <T>(branch, key, pageSize, files =>
 {
     processPage(files);
     return(Task.CompletedTask);
 });