public async Task GetInstanceConfigAsync() { Mock <InstanceAdmin.InstanceAdminClient> mockGrpcClient = new Mock <InstanceAdmin.InstanceAdminClient>(MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()) .Returns(new Mock <Operations.OperationsClient>().Object); GetInstanceConfigRequest expectedRequest = new GetInstanceConfigRequest { InstanceConfigName = new InstanceConfigName("[PROJECT]", "[INSTANCE_CONFIG]"), }; InstanceConfig expectedResponse = new InstanceConfig { InstanceConfigName = new InstanceConfigName("[PROJECT]", "[INSTANCE_CONFIG]"), DisplayName = "displayName1615086568", }; mockGrpcClient.Setup(x => x.GetInstanceConfigAsync(expectedRequest, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <InstanceConfig>(Task.FromResult(expectedResponse), null, null, null, null)); InstanceAdminClient client = new InstanceAdminClientImpl(mockGrpcClient.Object, null); InstanceConfigName name = new InstanceConfigName("[PROJECT]", "[INSTANCE_CONFIG]"); InstanceConfig response = await client.GetInstanceConfigAsync(name); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
/// <summary>Snippet for GetInstanceConfig</summary> public void GetInstanceConfig_RequestObject() { // Snippet: GetInstanceConfig(GetInstanceConfigRequest,CallSettings) // Create client InstanceAdminClient instanceAdminClient = InstanceAdminClient.Create(); // Initialize request argument(s) GetInstanceConfigRequest request = new GetInstanceConfigRequest { InstanceConfigName = new InstanceConfigName("[PROJECT]", "[INSTANCE_CONFIG]"), }; // Make the request InstanceConfig response = instanceAdminClient.GetInstanceConfig(request); // End snippet }
public async Task GetInstanceConfigAsync_RequestObject() { // Snippet: GetInstanceConfigAsync(GetInstanceConfigRequest,CallSettings) // Create client InstanceAdminClient instanceAdminClient = await InstanceAdminClient.CreateAsync(); // Initialize request argument(s) GetInstanceConfigRequest request = new GetInstanceConfigRequest { Name = new InstanceConfigName("[PROJECT]", "[INSTANCE_CONFIG]").ToString(), }; // Make the request InstanceConfig response = await instanceAdminClient.GetInstanceConfigAsync(request); // End snippet }
public void GetInstanceConfig2() { Mock <InstanceAdmin.InstanceAdminClient> mockGrpcClient = new Mock <InstanceAdmin.InstanceAdminClient>(MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()) .Returns(new Mock <Operations.OperationsClient>().Object); GetInstanceConfigRequest request = new GetInstanceConfigRequest { InstanceConfigName = new InstanceConfigName("[PROJECT]", "[INSTANCE_CONFIG]"), }; InstanceConfig expectedResponse = new InstanceConfig { InstanceConfigName = new InstanceConfigName("[PROJECT]", "[INSTANCE_CONFIG]"), DisplayName = "displayName1615086568", }; mockGrpcClient.Setup(x => x.GetInstanceConfig(request, It.IsAny <CallOptions>())) .Returns(expectedResponse); InstanceAdminClient client = new InstanceAdminClientImpl(mockGrpcClient.Object, null); InstanceConfig response = client.GetInstanceConfig(request); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }