public async stt::Task GetRequestObjectAsync()
        {
            moq::Mock <NodeTemplates.NodeTemplatesClient> mockGrpcClient = new moq::Mock <NodeTemplates.NodeTemplatesClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClientForRegionOperations()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetNodeTemplateRequest request = new GetNodeTemplateRequest
            {
                Region       = "regionedb20d96",
                Project      = "projectaa6ff846",
                NodeTemplate = "node_template118e38ae",
            };
            NodeTemplate expectedResponse = new NodeTemplate
            {
                Id   = 11672635353343658936UL,
                Kind = "kindf7aa39d9",
                Name = "name1c9368b0",
                CreationTimestamp = "creation_timestamp235e59a1",
                Disks             = { new LocalDisk(), },
                Region            = "regionedb20d96",
                Status            = NodeTemplate.Types.Status.Ready,
                ServerBinding     = new ServerBinding(),
                CpuOvercommitType = NodeTemplate.Types.CpuOvercommitType.UndefinedCpuOvercommitType,
                Accelerators      =
                {
                    new AcceleratorConfig(),
                },
                StatusMessage       = "status_message2c618f86",
                NodeTypeFlexibility = new NodeTemplateNodeTypeFlexibility(),
                NodeAffinityLabels  =
                {
                    {
                        "key8a0b6e3c",
                        "value60c16320"
                    },
                },
                Description = "description2cf9da67",
                SelfLink    = "self_link7e87f12d",
                NodeType    = "node_type98c685da",
            };

            mockGrpcClient.Setup(x => x.GetAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <NodeTemplate>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            NodeTemplatesClient client = new NodeTemplatesClientImpl(mockGrpcClient.Object, null);
            NodeTemplate        responseCallSettings = await client.GetAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            NodeTemplate responseCancellationToken = await client.GetAsync(request, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Exemplo n.º 2
0
 /// <summary>Snippet for Get</summary>
 public void GetRequestObject()
 {
     // Snippet: Get(GetNodeTemplateRequest, CallSettings)
     // Create client
     NodeTemplatesClient nodeTemplatesClient = NodeTemplatesClient.Create();
     // Initialize request argument(s)
     GetNodeTemplateRequest request = new GetNodeTemplateRequest
     {
         Region       = "",
         Project      = "",
         NodeTemplate = "",
     };
     // Make the request
     NodeTemplate response = nodeTemplatesClient.Get(request);
     // End snippet
 }
        public void GetRequestObject()
        {
            moq::Mock <NodeTemplates.NodeTemplatesClient> mockGrpcClient = new moq::Mock <NodeTemplates.NodeTemplatesClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClientForRegionOperations()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetNodeTemplateRequest request = new GetNodeTemplateRequest
            {
                Region       = "regionedb20d96",
                Project      = "projectaa6ff846",
                NodeTemplate = "node_template118e38ae",
            };
            NodeTemplate expectedResponse = new NodeTemplate
            {
                Id   = 11672635353343658936UL,
                Kind = "kindf7aa39d9",
                Name = "name1c9368b0",
                CreationTimestamp = "creation_timestamp235e59a1",
                Disks             = { new LocalDisk(), },
                Region            = "regionedb20d96",
                Status            = "status5444cb9a",
                ServerBinding     = new ServerBinding(),
                CpuOvercommitType = "cpu_overcommit_type8fdfbfa8",
                Accelerators      =
                {
                    new AcceleratorConfig(),
                },
                StatusMessage       = "status_message2c618f86",
                NodeTypeFlexibility = new NodeTemplateNodeTypeFlexibility(),
                NodeAffinityLabels  =
                {
                    {
                        "key8a0b6e3c",
                        "value60c16320"
                    },
                },
                Description = "description2cf9da67",
                SelfLink    = "self_link7e87f12d",
                NodeType    = "node_type98c685da",
            };

            mockGrpcClient.Setup(x => x.Get(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            NodeTemplatesClient client   = new NodeTemplatesClientImpl(mockGrpcClient.Object, null);
            NodeTemplate        response = client.Get(request);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Exemplo n.º 4
0
        /// <summary>Snippet for GetAsync</summary>
        public async Task GetRequestObjectAsync()
        {
            // Snippet: GetAsync(GetNodeTemplateRequest, CallSettings)
            // Additional: GetAsync(GetNodeTemplateRequest, CancellationToken)
            // Create client
            NodeTemplatesClient nodeTemplatesClient = await NodeTemplatesClient.CreateAsync();

            // Initialize request argument(s)
            GetNodeTemplateRequest request = new GetNodeTemplateRequest
            {
                Region       = "",
                Project      = "",
                NodeTemplate = "",
            };
            // Make the request
            NodeTemplate response = await nodeTemplatesClient.GetAsync(request);

            // End snippet
        }