public async Task EnsuresNonNullArguments() { var client = new RepositoryBranchesClient(Substitute.For <IApiConnection>()); var update = new BranchProtectionSettingsUpdate( new BranchProtectionRequiredStatusChecksUpdate(true, true, new[] { "test" })); await Assert.ThrowsAsync <ArgumentNullException>(() => client.UpdateBranchProtection(null, "repo", "branch", update)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.UpdateBranchProtection("owner", null, "branch", update)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.UpdateBranchProtection("owner", "repo", null, update)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.UpdateBranchProtection("owner", "repo", "branch", null)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.UpdateBranchProtection(1, null, update)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.UpdateBranchProtection(1, "branch", null)); await Assert.ThrowsAsync <ArgumentException>(() => client.UpdateBranchProtection("", "repo", "branch", update)); await Assert.ThrowsAsync <ArgumentException>(() => client.UpdateBranchProtection("owner", "", "branch", update)); await Assert.ThrowsAsync <ArgumentException>(() => client.UpdateBranchProtection("owner", "repo", "", update)); await Assert.ThrowsAsync <ArgumentException>(() => client.UpdateBranchProtection(1, "", update)); }
public void RequestsTheCorrectUrlWithRepositoryId() { var connection = Substitute.For <IApiConnection>(); var client = new RepositoryBranchesClient(connection); var update = new BranchProtectionSettingsUpdate( new BranchProtectionRequiredStatusChecksUpdate(true, true, new[] { "test" })); const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; client.UpdateBranchProtection(1, "branch", update); connection.Received() .Put <BranchProtectionSettings>(Arg.Is <Uri>(u => u.ToString() == "repositories/1/branches/branch/protection"), Arg.Any <BranchProtectionSettingsUpdate>(), null, previewAcceptsHeader); }
public async Task EnsuresNonNullArguments() { var client = new RepositoryBranchesClient(Substitute.For<IApiConnection>()); var update = new BranchProtectionSettingsUpdate( new BranchProtectionRequiredStatusChecksUpdate(true, true, new[] { "test" })); await Assert.ThrowsAsync<ArgumentNullException>(() => client.UpdateBranchProtection(null, "repo", "branch", update)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.UpdateBranchProtection("owner", null, "branch", update)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.UpdateBranchProtection("owner", "repo", null, update)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.UpdateBranchProtection("owner", "repo", "branch", null)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.UpdateBranchProtection(1, null, update)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.UpdateBranchProtection(1, "branch", null)); await Assert.ThrowsAsync<ArgumentException>(() => client.UpdateBranchProtection("", "repo", "branch", update)); await Assert.ThrowsAsync<ArgumentException>(() => client.UpdateBranchProtection("owner", "", "branch", update)); await Assert.ThrowsAsync<ArgumentException>(() => client.UpdateBranchProtection("owner", "repo", "", update)); await Assert.ThrowsAsync<ArgumentException>(() => client.UpdateBranchProtection(1, "", update)); }
public void RequestsTheCorrectUrlWithRepositoryId() { var connection = Substitute.For<IApiConnection>(); var client = new RepositoryBranchesClient(connection); var update = new BranchProtectionSettingsUpdate( new BranchProtectionRequiredStatusChecksUpdate(true, true, new[] { "test" })); const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; client.UpdateBranchProtection(1, "branch", update); connection.Received() .Put<BranchProtectionSettings>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection"), Arg.Any<BranchProtectionSettingsUpdate>(), null, previewAcceptsHeader); }