public void RepositoriesShouldInitiallyBeEmpty() { var service = CreateVSGitServices("repo1", "repo2"); var target = new LocalRepositories(service); Assert.That(target.Repositories, Is.Empty); }
public async Task RefreshShouldLoadRepositories() { var service = CreateVSGitServices("repo1", "repo2"); var target = new LocalRepositories(service); await target.Refresh(); Assert.That( new[] { "repo1", "repo2" }, Is.EqualTo(target.Repositories.Select(x => x.Name).ToList())); }
public async Task GetRepositoriesForAddressShouldSortRepositories() { var service = CreateVSGitServices("c", "a", "b"); var target = new LocalRepositories(service); await target.Refresh(); var result = target.GetRepositoriesForAddress(HostAddress.Create(GitHubAddress)); Assert.That( new[] { "a", "b", "c" }, Is.EqualTo(result.Select(x => x.Name).ToList())); }
public async Task GetRepositoriesForAddressShouldFilterRepositories() { var service = CreateVSGitServices( Tuple.Create("repo1", GitHubAddress), Tuple.Create("repo2", GitHubAddress), Tuple.Create("repo2", "https://another.com")); var target = new LocalRepositories(service); await target.Refresh(); Assert.That(3, Is.EqualTo(target.Repositories.Count)); var result = target.GetRepositoriesForAddress(HostAddress.Create(GitHubAddress)); Assert.That(2, Is.EqualTo(result.Count)); }
public async Task RefreshShouldRemoveRepository() { var service = CreateVSGitServices("repo1", "repo2"); var target = new LocalRepositories(service); await target.Refresh(); Assert.That(2, Is.EqualTo(target.Repositories.Count)); var existing = service.GetKnownRepositories(); service.GetKnownRepositories().Returns(existing.Skip(1).Take(1)); await target.Refresh(); Assert.That( new[] { "repo2" }, Is.EqualTo(target.Repositories.Select(x => x.Name).ToList())); }
public async Task RefreshShouldAddNewRepository() { var service = CreateVSGitServices("repo1", "repo2"); var target = new LocalRepositories(service, new JoinableTaskContext()); await target.Refresh(); Assert.That(2, Is.EqualTo(target.Repositories.Count)); var existing = service.GetKnownRepositories(); var newRepo = CreateRepository("new"); service.GetKnownRepositories().Returns(existing.Concat(new[] { newRepo })); await target.Refresh(); Assert.That( new[] { "repo1", "repo2", "new" }, Is.EqualTo(target.Repositories.Select(x => x.Name).ToList())); }