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); }
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(); }
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); }
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); }
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); }
public GitApiController(IGitDb gitDb) { _gitDb = 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); });