public async stt::Task CreateServiceConfigAsync() { moq::Mock <ServiceManager.ServiceManagerClient> mockGrpcClient = new moq::Mock <ServiceManager.ServiceManagerClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); CreateServiceConfigRequest request = new CreateServiceConfigRequest { ServiceName = "service_named5df05d5", ServiceConfig = new ga::Service(), }; ga::Service expectedResponse = new ga::Service { Name = "name1c9368b0", Title = "title17dbd3d5", Apis = { new wkt::Api(), }, Types_ = { new wkt::Type(), }, Enums = { new wkt::Enum(), }, Documentation = new ga::Documentation(), Backend = new ga::Backend(), Http = new ga::Http(), Quota = new ga::Quota(), Authentication = new ga::Authentication(), Context = new ga::Context(), Usage = new ga::Usage(), Endpoints = { new ga::Endpoint(), }, #pragma warning disable CS0612 ConfigVersion = 2430367190U, #pragma warning restore CS0612 Control = new ga::Control(), ProducerProjectId = "producer_project_id18d0012a", Logs = { new ga::LogDescriptor(), }, Metrics = { new ga::MetricDescriptor(), }, MonitoredResources = { new ga::MonitoredResourceDescriptor(), }, Billing = new ga::Billing(), Logging = new ga::Logging(), Monitoring = new ga::Monitoring(), SystemParameters = new ga::SystemParameters(), Id = "id74b70bb8", SourceInfo = new ga::SourceInfo(), }; mockGrpcClient.Setup(x => x.CreateServiceConfigAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <ga::Service>(stt::Task.FromResult(expectedResponse), null, null, null, null)); ServiceManagerClient client = new ServiceManagerClientImpl(mockGrpcClient.Object, null); ga::Service responseCallSettings = await client.CreateServiceConfigAsync(request.ServiceName, request.ServiceConfig, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); ga::Service responseCancellationToken = await client.CreateServiceConfigAsync(request.ServiceName, request.ServiceConfig, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public void GetServiceConfig() { moq::Mock <ServiceManager.ServiceManagerClient> mockGrpcClient = new moq::Mock <ServiceManager.ServiceManagerClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); GetServiceConfigRequest request = new GetServiceConfigRequest { ServiceName = "service_named5df05d5", ConfigId = "config_id908a73d1", View = GetServiceConfigRequest.Types.ConfigView.Full, }; ga::Service expectedResponse = new ga::Service { Name = "name1c9368b0", Title = "title17dbd3d5", Apis = { new wkt::Api(), }, Types_ = { new wkt::Type(), }, Enums = { new wkt::Enum(), }, Documentation = new ga::Documentation(), Backend = new ga::Backend(), Http = new ga::Http(), Quota = new ga::Quota(), Authentication = new ga::Authentication(), Context = new ga::Context(), Usage = new ga::Usage(), Endpoints = { new ga::Endpoint(), }, #pragma warning disable CS0612 ConfigVersion = 2430367190U, #pragma warning restore CS0612 Control = new ga::Control(), ProducerProjectId = "producer_project_id18d0012a", Logs = { new ga::LogDescriptor(), }, Metrics = { new ga::MetricDescriptor(), }, MonitoredResources = { new ga::MonitoredResourceDescriptor(), }, Billing = new ga::Billing(), Logging = new ga::Logging(), Monitoring = new ga::Monitoring(), SystemParameters = new ga::SystemParameters(), Id = "id74b70bb8", SourceInfo = new ga::SourceInfo(), }; mockGrpcClient.Setup(x => x.GetServiceConfig(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); ServiceManagerClient client = new ServiceManagerClientImpl(mockGrpcClient.Object, null); ga::Service response = client.GetServiceConfig(request.ServiceName, request.ConfigId, request.View); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }