Пример #1
0
        public async stt::Task GetServiceRequestObjectAsync()
        {
            moq::Mock <DataprocMetastore.DataprocMetastoreClient> mockGrpcClient = new moq::Mock <DataprocMetastore.DataprocMetastoreClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetServiceRequest request = new GetServiceRequest
            {
                ServiceName = ServiceName.FromProjectLocationService("[PROJECT]", "[LOCATION]", "[SERVICE]"),
            };
            Service expectedResponse = new Service
            {
                ServiceName = ServiceName.FromProjectLocationService("[PROJECT]", "[LOCATION]", "[SERVICE]"),
                CreateTime  = new wkt::Timestamp(),
                UpdateTime  = new wkt::Timestamp(),
                Labels      =
                {
                    {
                        "key8a0b6e3c",
                        "value60c16320"
                    },
                },
                HiveMetastoreConfig  = new HiveMetastoreConfig(),
                NetworkAsNetworkName = NetworkName.FromProjectNetwork("[PROJECT]", "[NETWORK]"),
                EndpointUri          = "endpoint_uri59c03c94",
                Port                = -78310000,
                State               = Service.Types.State.Deleting,
                StateMessage        = "state_message46cf28c0",
                ArtifactGcsUri      = "artifact_gcs_uri4d2b3985",
                Tier                = Service.Types.Tier.Developer,
                MetadataIntegration = new MetadataIntegration(),
                MaintenanceWindow   = new MaintenanceWindow(),
                Uid = "uida2d37198",
                MetadataManagementActivity = new MetadataManagementActivity(),
                ReleaseChannel             = Service.Types.ReleaseChannel.Stable,
            };

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

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

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }