Пример #1
0
            public void CallsIntoClient()
            {
                var github = Substitute.For <IGitHubClient>();
                var client = new ObservableRepositoriesClient(github);
                var update = new BranchUpdate();

                client.EditBranch("owner", "repo", "branch", update);

                github.Repository.Received(1).EditBranch("owner", "repo", "branch", update);
            }
            public async Task EnsuresNonNullArguments()
            {
                var client = new ObservableRepositoriesClient(Substitute.For <IGitHubClient>());
                var update = new BranchUpdate();

                Assert.Throws <ArgumentNullException>(() => client.EditBranch(null, "repo", "branch", update));
                Assert.Throws <ArgumentNullException>(() => client.EditBranch("owner", null, "branch", update));
                Assert.Throws <ArgumentNullException>(() => client.EditBranch("owner", "repo", null, update));
                Assert.Throws <ArgumentNullException>(() => client.EditBranch("owner", "repo", "branch", null));

                Assert.Throws <ArgumentNullException>(() => client.EditBranch(1, null, update));
                Assert.Throws <ArgumentNullException>(() => client.EditBranch(1, "branch", null));

                Assert.Throws <ArgumentException>(() => client.EditBranch("", "repo", "branch", update));
                Assert.Throws <ArgumentException>(() => client.EditBranch("owner", "", "branch", update));
                Assert.Throws <ArgumentException>(() => client.EditBranch("owner", "repo", "", update));

                Assert.Throws <ArgumentException>(() => client.EditBranch(1, "", update));
            }
            public void PatchsTheCorrectUrlWithRepositoryId()
            {
                var github = Substitute.For <IGitHubClient>();
                var client = new ObservableRepositoriesClient(github);
                var update = new BranchUpdate();

                client.EditBranch(1, "branch", update);

                github.Repository.Branch.Received(1).Edit(1, "branch", update);
            }
Пример #4
0
            public async Task EnsuresArguments()
            {
                var github            = Substitute.For <IGitHubClient>();
                var nonreactiveClient = new RepositoriesClient(Substitute.For <IApiConnection>());

                github.Repository.Returns(nonreactiveClient);
                var client = new ObservableRepositoriesClient(github);
                var update = new BranchUpdate();

                Assert.Throws <ArgumentNullException>(() => client.EditBranch(null, "repo", "branch", update));
                Assert.Throws <ArgumentNullException>(() => client.EditBranch("owner", null, "branch", update));
                Assert.Throws <ArgumentNullException>(() => client.EditBranch("owner", "repo", null, update));
                Assert.Throws <ArgumentNullException>(() => client.EditBranch("owner", "repo", "branch", null));
                Assert.Throws <ArgumentException>(() => client.EditBranch("", "repo", "branch", update));
                Assert.Throws <ArgumentException>(() => client.EditBranch("owner", "", "branch", update));
                Assert.Throws <ArgumentException>(() => client.EditBranch("owner", "repo", "", update));
            }