コード例 #1
0
        public void EnsuresNonEmptyArguments()
        {
            var client = new DeploymentsClient(Substitute.For <IApiConnection>());

            Assert.Throws <ArgumentException>(() => client.Create("", "name", newDeployment));
            Assert.Throws <ArgumentException>(() => client.Create("owner", "", newDeployment));
        }
コード例 #2
0
        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));
        }
コード例 #3
0
        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));
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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));
        }
コード例 #6
0
        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>());
        }
コード例 #7
0
        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);
        }
コード例 #8
0
        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));
        }
コード例 #9
0
        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");
        }
コード例 #10
0
 /// <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
 }
コード例 #11
0
 /// <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
 }
コード例 #12
0
        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");
        }
コード例 #13
0
        /// <summary>Snippet for ListDeployments</summary>
        public void ListDeploymentsRequestObject()
        {
            // Snippet: ListDeployments(ListDeploymentsRequest, CallSettings)
            // Create client
            DeploymentsClient deploymentsClient = DeploymentsClient.Create();
            // Initialize request argument(s)
            ListDeploymentsRequest request = new ListDeploymentsRequest
            {
                ParentAsEnvironmentName = EnvironmentName.FromProjectLocationAgentEnvironment("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENVIRONMENT]"),
            };
            // Make the request
            PagedEnumerable <ListDeploymentsResponse, Deployment> response = deploymentsClient.ListDeployments(request);

            // 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
        }