public async stt::Task GetTenantResourceNamesAsync()
        {
            moq::Mock <TenantService.TenantServiceClient> mockGrpcClient = new moq::Mock <TenantService.TenantServiceClient>(moq::MockBehavior.Strict);
            GetTenantRequest request = new GetTenantRequest
            {
                TenantName = TenantName.FromProjectTenant("[PROJECT]", "[TENANT]"),
            };
            Tenant expectedResponse = new Tenant
            {
                TenantName = TenantName.FromProjectTenant("[PROJECT]", "[TENANT]"),
                ExternalId = "external_id9442680e",
                UsageType  = Tenant.Types.DataUsageType.Unspecified,
                KeywordSearchableProfileCustomAttributes =
                {
                    "keyword_searchable_profile_custom_attributes9dbf9d03",
                },
            };

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

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            Tenant responseCancellationToken = await client.GetTenantAsync(request.TenantName, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
        public async stt::Task GetTenantAsync()
        {
            moq::Mock <TenantService.TenantServiceClient> mockGrpcClient = new moq::Mock <TenantService.TenantServiceClient>(moq::MockBehavior.Strict);
            GetTenantRequest request = new GetTenantRequest
            {
                TenantName = TenantName.FromProjectTenant("[PROJECT]", "[TENANT]"),
            };
            Tenant expectedResponse = new Tenant
            {
                TenantName = TenantName.FromProjectTenant("[PROJECT]", "[TENANT]"),
                ExternalId = "external_id9442680e",
            };

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

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            Tenant responseCancellationToken = await client.GetTenantAsync(request.Name, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Beispiel #3
0
        public async Task GetTenantAsync2()
        {
            Mock <TenantService.TenantServiceClient> mockGrpcClient = new Mock <TenantService.TenantServiceClient>(MockBehavior.Strict);
            GetTenantRequest request = new GetTenantRequest
            {
                TenantName = new TenantName("[PROJECT]", "[TENANT]"),
            };
            Tenant expectedResponse = new Tenant
            {
                TenantName = new TenantName("[PROJECT]", "[TENANT]"),
                ExternalId = "externalId-1153075697",
            };

            mockGrpcClient.Setup(x => x.GetTenantAsync(request, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <Tenant>(Task.FromResult(expectedResponse), null, null, null, null));
            TenantServiceClient client = new TenantServiceClientImpl(mockGrpcClient.Object, null);
            Tenant response            = await client.GetTenantAsync(request);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }