public void EnsuresNonWhitespaceArguments(string whitespace) { var client = new DeploymentsClient(Substitute.For <IApiConnection>()); Assert.Throws <ArgumentException>(() => client.Create(whitespace, "name", newDeployment)); Assert.Throws <ArgumentException>(() => client.Create("owner", whitespace, newDeployment)); }
public void EnsuresNonEmptyArguments() { var client = new DeploymentsClient(Substitute.For <IApiConnection>()); Assert.Throws <ArgumentException>(() => client.Create("", "name", newDeployment)); Assert.Throws <ArgumentException>(() => client.Create("owner", "", newDeployment)); }
public async void EnsuresNonNullArguments() { var client = new DeploymentsClient(Substitute.For <IApiConnection>()); Assert.Throws <ArgumentNullException>(() => client.GetAll(null, "name")); Assert.Throws <ArgumentNullException>(() => client.GetAll("owner", null)); }
/// <summary> /// Initializes a new instance of the Sample class. /// </summary> /// <exception cref="ArgumentNullException">Thrown when one or more required arguments are null.</exception> /// <param name="tenantId">Identifier for the tenant.</param> /// <param name="clientId">Identifier for the client.</param> /// <param name="clientSecret">The client secret.</param> /// <param name="accountEndpoint">The account endpoint.</param> /// <param name="instance">The instance.</param> /// <param name="connectionString">The connection string.</param> /// <param name="deviceId">Identifier for the device.</param> /// <param name="deviceTag">Device tag.</param> /// <param name="delete">Boolean flag to indicate whether the update should be deleted when finished.</param> public Sample(string tenantId, string clientId, string clientSecret, string accountEndpoint, string instance, string connectionString, string deviceId, string deviceTag, bool delete) { if (tenantId == null) { throw new ArgumentNullException(nameof(tenantId)); } if (clientId == null) { throw new ArgumentNullException(nameof(clientId)); } if (clientSecret == null) { throw new ArgumentNullException(nameof(clientSecret)); } _accountEndpoint = accountEndpoint ?? throw new ArgumentNullException(nameof(accountEndpoint)); _instanceId = instance ?? throw new ArgumentNullException(nameof(instance)); _connectionString = connectionString ?? throw new ArgumentNullException(nameof(connectionString)); _deviceId = deviceId ?? throw new ArgumentNullException(nameof(deviceId)); _deviceTag = deviceTag ?? throw new ArgumentNullException(nameof(deviceTag)); _delete = delete; var credentials = new ClientSecretCredential(tenantId, clientId, clientSecret); _updatesClient = new UpdatesClient(accountEndpoint, instance, credentials); _devicesClient = new DevicesClient(accountEndpoint, instance, credentials); _deploymentsClient = new DeploymentsClient(accountEndpoint, instance, credentials); }
public async Task EnsuresNonEmptyArguments() { var client = new DeploymentsClient(Substitute.For <IApiConnection>()); Assert.Throws <ArgumentException>(() => client.GetAll("", "name")); Assert.Throws <ArgumentException>(() => client.GetAll("owner", "")); }
private void SetupWithNonReactiveClient() { var deploymentsClient = new DeploymentsClient(Substitute.For <IApiConnection>()); _githubClient.Repository.Deployment.Returns(deploymentsClient); _client = new ObservableDeploymentsClient(_githubClient); }
public async Task EnsuresNonWhitespaceArguments(string whitespace) { var client = new DeploymentsClient(Substitute.For <IApiConnection>()); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAll(whitespace, "name")); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAll("owner", whitespace)); }
public void RequestsCorrectUrl() { var connection = Substitute.For <IApiConnection>(); var client = new DeploymentsClient(connection); var expectedUrl = "repos/owner/name/deployments"; client.GetAll("owner", "name"); connection.Received(1).GetAll <Deployment>(Arg.Is <Uri>(u => u.ToString() == expectedUrl)); }
public async Task EnsuresNonNullArguments() { var client = new DeploymentsClient(Substitute.For <IApiConnection>()); await Assert.ThrowsAsync <ArgumentNullException>(() => client.Create(null, "name", newDeployment)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.Create("owner", null, newDeployment)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.Create("owner", "name", null)); }
public void RequestsCorrectUrl() { var connection = Substitute.For <IApiConnection>(); var client = new DeploymentsClient(connection); var expectedUrl = string.Format("repos/{0}/{1}/deployments", owner, name); client.GetAll(owner, name); connection.Received(1) .GetAll <Deployment>(Arg.Is <Uri>(u => u.ToString() == expectedUrl), Args.ApiOptions); }
public void UsesPreviewAcceptsHeader() { var connection = Substitute.For <IApiConnection>(); var client = new DeploymentsClient(connection); client.Create("owner", "name", newDeployment); connection.Received().Post <Deployment>(Arg.Any <Uri>(), Arg.Any <NewDeployment>(), Arg.Is(ExpectedAcceptHeader)); }
public void UsesPreviewAcceptsHeader() { var connection = Substitute.For <IApiConnection>(); var client = new DeploymentsClient(connection); client.GetAll("owner", "name"); connection.Received().GetAll <Deployment>(Arg.Any <Uri>(), Arg.Any <IDictionary <string, string> >(), ExpectedAcceptHeader); }
public async Task EnsuresNonNullArguments() { var client = new DeploymentsClient(Substitute.For <IApiConnection>()); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAll(null, name)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAll(owner, null)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAll(owner, name, null)); }
public void PassesNewDeploymentRequest() { var connection = Substitute.For <IApiConnection>(); var client = new DeploymentsClient(connection); client.Create("owner", "name", newDeployment); connection.Received(1).Post <Deployment>(Arg.Any <Uri>(), newDeployment); }
/// <summary>Snippet for GetDeployment</summary> public void GetDeployment() { // Snippet: GetDeployment(string, CallSettings) // Create client DeploymentsClient deploymentsClient = DeploymentsClient.Create(); // Initialize request argument(s) string name = "projects/[PROJECT]/locations/[LOCATION]/agents/[AGENT]/environments/[ENVIRONMENT]/deployments/[DEPLOYMENT]"; // Make the request Deployment response = deploymentsClient.GetDeployment(name); // End snippet }
public void PostsToDeploymentsUrlWithRepositoryId() { var connection = Substitute.For <IApiConnection>(); var client = new DeploymentsClient(connection); var expectedUrl = "repositories/1/deployments"; client.Create(1, newDeployment); connection.Received(1).Post <Deployment>(Arg.Is <Uri>(uri => uri.ToString() == expectedUrl), newDeployment); }
/// <summary>Snippet for GetDeployment</summary> public void GetDeploymentResourceNames() { // Snippet: GetDeployment(DeploymentName, CallSettings) // Create client DeploymentsClient deploymentsClient = DeploymentsClient.Create(); // Initialize request argument(s) DeploymentName name = DeploymentName.FromProjectLocationAgentEnvironmentDeployment("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENVIRONMENT]", "[DEPLOYMENT]"); // Make the request Deployment response = deploymentsClient.GetDeployment(name); // End snippet }
public void SendsPreviewAcceptHeaders() { var connection = Substitute.For <IApiConnection>(); var client = new DeploymentsClient(connection); client.Create("owner", "name", newDeployment); connection.Received(1).Post <Deployment>(Arg.Any <Uri>(), Arg.Any <NewDeployment>(), "application/vnd.github.ant-man-preview+json"); }
public void SendsPreviewAcceptHeaders() { var connection = Substitute.For <IApiConnection>(); var client = new DeploymentsClient(connection); client.Create("owner", "name", newDeployment); connection.Received(1).Post <Deployment>(Arg.Any <Uri>(), Arg.Any <NewDeployment>(), Arg.Is <string>(s => s == AcceptHeaders.DeploymentApiPreview)); }
public void PostsToDeploymentsUrl() { var connection = Substitute.For <IApiConnection>(); var client = new DeploymentsClient(connection); var expectedUrl = "repos/owner/name/deployments"; client.Create("owner", "name", newDeployment); connection.Received(1).Post <Deployment>(Arg.Is <Uri>(u => u.ToString() == expectedUrl), Arg.Any <NewDeployment>()); }
public void PostsToDeploymentsUrl() { var connection = Substitute.For <IApiConnection>(); var client = new DeploymentsClient(connection); var expectedUrl = "repos/owner/name/deployments"; client.Create("owner", "name", newDeployment); connection.Received(1).Post <Deployment>(Arg.Is <Uri>(u => u.ToString() == expectedUrl), newDeployment, "application/vnd.github.ant-man-preview+json"); }
public async Task RequestsCorrectUrlWithRepositoryId() { var connection = Substitute.For <IApiConnection>(); var client = new DeploymentsClient(connection); var expectedUrl = string.Format("repositories/{0}/deployments", repositoryId); await client.GetAll(repositoryId); connection.Received(1) .GetAll <Deployment>(Arg.Is <Uri>(u => u.ToString() == expectedUrl), Args.ApiOptions); }
public void RequestsCorrectUrlWithPreviewAcceptHeaders() { var connection = Substitute.For <IApiConnection>(); var client = new DeploymentsClient(connection); var expectedUrl = string.Format("repos/{0}/{1}/deployments", owner, name); client.GetAll(owner, name); connection.Received(1) .GetAll <Deployment>(Arg.Is <Uri>(u => u.ToString() == expectedUrl), Arg.Any <IDictionary <string, string> >(), Arg.Is <string>(s => s == AcceptHeaders.DeploymentApiPreview), Args.ApiOptions); }
public async Task RequestsCorrectUrl() { var connection = Substitute.For <IApiConnection>(); var client = new DeploymentsClient(connection); var expectedUrl = string.Format("repos/{0}/{1}/deployments", owner, name); await client.GetAll(owner, name); connection.Received(1) .GetAll <Deployment>(Arg.Is <Uri>(u => u.ToString() == expectedUrl), null, "application/vnd.github.ant-man-preview+json", Args.ApiOptions); }
/// <summary>Snippet for GetDeploymentAsync</summary> public async Task GetDeploymentAsync() { // Snippet: GetDeploymentAsync(string, CallSettings) // Additional: GetDeploymentAsync(string, CancellationToken) // Create client DeploymentsClient deploymentsClient = await DeploymentsClient.CreateAsync(); // Initialize request argument(s) string name = "projects/[PROJECT]/locations/[LOCATION]/agents/[AGENT]/environments/[ENVIRONMENT]/deployments/[DEPLOYMENT]"; // Make the request Deployment response = await deploymentsClient.GetDeploymentAsync(name); // End snippet }
/// <summary>Snippet for GetDeploymentAsync</summary> public async Task GetDeploymentResourceNamesAsync() { // Snippet: GetDeploymentAsync(DeploymentName, CallSettings) // Additional: GetDeploymentAsync(DeploymentName, CancellationToken) // Create client DeploymentsClient deploymentsClient = await DeploymentsClient.CreateAsync(); // Initialize request argument(s) DeploymentName name = DeploymentName.FromProjectLocationAgentEnvironmentDeployment("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENVIRONMENT]", "[DEPLOYMENT]"); // Make the request Deployment response = await deploymentsClient.GetDeploymentAsync(name); // End snippet }
/// <summary>Snippet for ListDeploymentsAsync</summary> public async Task ListDeploymentsRequestObjectAsync() { // Snippet: ListDeploymentsAsync(ListDeploymentsRequest, CallSettings) // Create client DeploymentsClient deploymentsClient = await DeploymentsClient.CreateAsync(); // Initialize request argument(s) ListDeploymentsRequest request = new ListDeploymentsRequest { ParentAsEnvironmentName = EnvironmentName.FromProjectLocationAgentEnvironment("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENVIRONMENT]"), }; // Make the request PagedAsyncEnumerable <ListDeploymentsResponse, Deployment> response = deploymentsClient.ListDeploymentsAsync(request); // Iterate over all response items, lazily performing RPCs as required await response.ForEachAsync((Deployment item) => { // Do something with each item Console.WriteLine(item); }); // Or iterate over pages (of server-defined size), performing one RPC per page await response.AsRawResponses().ForEachAsync((ListDeploymentsResponse page) => { // Do something with each page of items Console.WriteLine("A page of results:"); foreach (Deployment item in page) { // Do something with each item Console.WriteLine(item); } }); // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required int pageSize = 10; Page <Deployment> singlePage = await response.ReadPageAsync(pageSize); // Do something with the page of items Console.WriteLine($"A page of {pageSize} results (unless it's the final page):"); foreach (Deployment item in singlePage) { // Do something with each item Console.WriteLine(item); } // Store the pageToken, for when the next page is required. string nextPageToken = singlePage.NextPageToken; // End snippet }
public void RequestsCorrectUrlWithApiOptions() { var connection = Substitute.For <IApiConnection>(); var client = new DeploymentsClient(connection); var expectedUrl = string.Format("repos/{0}/{1}/deployments", owner, name); var options = new ApiOptions { PageSize = 1, PageCount = 1, StartPage = 1 }; client.GetAll(owner, name, options); connection.Received(1) .GetAll <Deployment>(Arg.Is <Uri>(u => u.ToString() == expectedUrl), options); }
/// <summary>Snippet for ListDeployments</summary> public void ListDeploymentsResourceNames() { // Snippet: ListDeployments(EnvironmentName, string, int?, CallSettings) // Create client DeploymentsClient deploymentsClient = DeploymentsClient.Create(); // Initialize request argument(s) EnvironmentName parent = EnvironmentName.FromProjectLocationAgentEnvironment("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENVIRONMENT]"); // Make the request PagedEnumerable <ListDeploymentsResponse, Deployment> response = deploymentsClient.ListDeployments(parent); // Iterate over all response items, lazily performing RPCs as required foreach (Deployment item in response) { // Do something with each item Console.WriteLine(item); } // Or iterate over pages (of server-defined size), performing one RPC per page foreach (ListDeploymentsResponse page in response.AsRawResponses()) { // Do something with each page of items Console.WriteLine("A page of results:"); foreach (Deployment item in page) { // Do something with each item Console.WriteLine(item); } } // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required int pageSize = 10; Page <Deployment> singlePage = response.ReadPage(pageSize); // Do something with the page of items Console.WriteLine($"A page of {pageSize} results (unless it's the final page):"); foreach (Deployment item in singlePage) { // Do something with each item Console.WriteLine(item); } // Store the pageToken, for when the next page is required. string nextPageToken = singlePage.NextPageToken; // End snippet }
public async Task RequestsCorrectUrlWithRepostoryIdWithApiOptions() { var connection = Substitute.For <IApiConnection>(); var client = new DeploymentsClient(connection); var expectedUrl = string.Format("repositories/{0}/deployments", repositoryId); var options = new ApiOptions { PageSize = 1, PageCount = 1, StartPage = 1 }; await client.GetAll(repositoryId, options); connection.Received(1) .GetAll <Deployment>(Arg.Is <Uri>(u => u.ToString() == expectedUrl), options); }
private void SetupWithNonReactiveClient() { var deploymentsClient = new DeploymentsClient(Substitute.For<IApiConnection>()); _githubClient.Repository.Deployment.Returns(deploymentsClient); _client = new ObservableDeploymentsClient(_githubClient); }