コード例 #1
0
    public void RepositoriesShouldInitiallyBeEmpty()
    {
        var service = CreateVSGitServices("repo1", "repo2");
        var target  = new LocalRepositories(service);

        Assert.That(target.Repositories, Is.Empty);
    }
コード例 #2
0
    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()));
    }
コード例 #3
0
    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()));
    }
コード例 #4
0
    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));
    }
コード例 #5
0
    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()));
    }
コード例 #6
0
    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()));
    }