public async stt::Task UpdateEndpointAsync() { moq::Mock <EndpointService.EndpointServiceClient> mockGrpcClient = new moq::Mock <EndpointService.EndpointServiceClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); UpdateEndpointRequest request = new UpdateEndpointRequest { Endpoint = new Endpoint(), UpdateMask = new wkt::FieldMask(), }; Endpoint expectedResponse = new Endpoint { EndpointName = EndpointName.FromProjectLocationEndpoint("[PROJECT]", "[LOCATION]", "[ENDPOINT]"), DisplayName = "display_name137f65c2", Description = "description2cf9da67", DeployedModels = { new DeployedModel(), }, TrafficSplit = { { "key8a0b6e3c", 1623286560 }, }, Etag = "etage8ad7218", Labels = { { "key8a0b6e3c", "value60c16320" }, }, CreateTime = new wkt::Timestamp(), UpdateTime = new wkt::Timestamp(), EncryptionSpec = new EncryptionSpec(), NetworkAsNetworkName = NetworkName.FromProjectNetwork("[PROJECT]", "[NETWORK]"), ModelDeploymentMonitoringJobAsModelDeploymentMonitoringJobName = ModelDeploymentMonitoringJobName.FromProjectLocationModelDeploymentMonitoringJob("[PROJECT]", "[LOCATION]", "[MODEL_DEPLOYMENT_MONITORING_JOB]"), EnablePrivateServiceConnect = false, }; mockGrpcClient.Setup(x => x.UpdateEndpointAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Endpoint>(stt::Task.FromResult(expectedResponse), null, null, null, null)); EndpointServiceClient client = new EndpointServiceClientImpl(mockGrpcClient.Object, null); Endpoint responseCallSettings = await client.UpdateEndpointAsync(request.Endpoint, request.UpdateMask, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); Endpoint responseCancellationToken = await client.UpdateEndpointAsync(request.Endpoint, request.UpdateMask, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public void GetEndpointResourceNames() { moq::Mock <EndpointService.EndpointServiceClient> mockGrpcClient = new moq::Mock <EndpointService.EndpointServiceClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); GetEndpointRequest request = new GetEndpointRequest { EndpointName = EndpointName.FromProjectLocationEndpoint("[PROJECT]", "[LOCATION]", "[ENDPOINT]"), }; Endpoint expectedResponse = new Endpoint { EndpointName = EndpointName.FromProjectLocationEndpoint("[PROJECT]", "[LOCATION]", "[ENDPOINT]"), DisplayName = "display_name137f65c2", Description = "description2cf9da67", DeployedModels = { new DeployedModel(), }, TrafficSplit = { { "key8a0b6e3c", 1623286560 }, }, Etag = "etage8ad7218", Labels = { { "key8a0b6e3c", "value60c16320" }, }, CreateTime = new wkt::Timestamp(), UpdateTime = new wkt::Timestamp(), EncryptionSpec = new EncryptionSpec(), NetworkAsNetworkName = NetworkName.FromProjectNetwork("[PROJECT]", "[NETWORK]"), ModelDeploymentMonitoringJobAsModelDeploymentMonitoringJobName = ModelDeploymentMonitoringJobName.FromProjectLocationModelDeploymentMonitoringJob("[PROJECT]", "[LOCATION]", "[MODEL_DEPLOYMENT_MONITORING_JOB]"), EnablePrivateServiceConnect = false, }; mockGrpcClient.Setup(x => x.GetEndpoint(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); EndpointServiceClient client = new EndpointServiceClientImpl(mockGrpcClient.Object, null); Endpoint response = client.GetEndpoint(request.EndpointName); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }