public void Get() { moq::Mock <InstanceTemplates.InstanceTemplatesClient> mockGrpcClient = new moq::Mock <InstanceTemplates.InstanceTemplatesClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClientForGlobalOperations()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); GetInstanceTemplateRequest request = new GetInstanceTemplateRequest { Project = "projectaa6ff846", InstanceTemplate = "instance_template6cae3083", }; InstanceTemplate expectedResponse = new InstanceTemplate { Id = 11672635353343658936UL, Kind = "kindf7aa39d9", Name = "name1c9368b0", CreationTimestamp = "creation_timestamp235e59a1", SourceInstanceParams = new SourceInstanceParams(), Properties = new InstanceProperties(), SourceInstance = "source_instancea8512e83", Description = "description2cf9da67", SelfLink = "self_link7e87f12d", }; mockGrpcClient.Setup(x => x.Get(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); InstanceTemplatesClient client = new InstanceTemplatesClientImpl(mockGrpcClient.Object, null); InstanceTemplate response = client.Get(request.Project, request.InstanceTemplate); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async stt::Task GetRequestObjectAsync() { moq::Mock <InstanceTemplates.InstanceTemplatesClient> mockGrpcClient = new moq::Mock <InstanceTemplates.InstanceTemplatesClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClientForGlobalOperations()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); GetInstanceTemplateRequest request = new GetInstanceTemplateRequest { Project = "projectaa6ff846", InstanceTemplate = "instance_template6cae3083", }; InstanceTemplate expectedResponse = new InstanceTemplate { Id = 11672635353343658936UL, Kind = "kindf7aa39d9", Name = "name1c9368b0", CreationTimestamp = "creation_timestamp235e59a1", SourceInstanceParams = new SourceInstanceParams(), Properties = new InstanceProperties(), SourceInstance = "source_instancea8512e83", Description = "description2cf9da67", SelfLink = "self_link7e87f12d", }; mockGrpcClient.Setup(x => x.GetAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <InstanceTemplate>(stt::Task.FromResult(expectedResponse), null, null, null, null)); InstanceTemplatesClient client = new InstanceTemplatesClientImpl(mockGrpcClient.Object, null); InstanceTemplate responseCallSettings = await client.GetAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); InstanceTemplate responseCancellationToken = await client.GetAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
/// <summary>Snippet for Get</summary> public void GetRequestObject() { // Snippet: Get(GetInstanceTemplateRequest, CallSettings) // Create client InstanceTemplatesClient instanceTemplatesClient = InstanceTemplatesClient.Create(); // Initialize request argument(s) GetInstanceTemplateRequest request = new GetInstanceTemplateRequest { Project = "", InstanceTemplate = "", }; // Make the request InstanceTemplate response = instanceTemplatesClient.Get(request); // End snippet }
/// <summary>Snippet for GetAsync</summary> public async Task GetRequestObjectAsync() { // Snippet: GetAsync(GetInstanceTemplateRequest, CallSettings) // Additional: GetAsync(GetInstanceTemplateRequest, CancellationToken) // Create client InstanceTemplatesClient instanceTemplatesClient = await InstanceTemplatesClient.CreateAsync(); // Initialize request argument(s) GetInstanceTemplateRequest request = new GetInstanceTemplateRequest { Project = "", InstanceTemplate = "", }; // Make the request InstanceTemplate response = await instanceTemplatesClient.GetAsync(request); // End snippet }