Example #1
0
        public async stt::Task UpdateIndexEndpointAsync()
        {
            moq::Mock <IndexEndpointService.IndexEndpointServiceClient> mockGrpcClient = new moq::Mock <IndexEndpointService.IndexEndpointServiceClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            UpdateIndexEndpointRequest request = new UpdateIndexEndpointRequest
            {
                IndexEndpoint = new IndexEndpoint(),
                UpdateMask    = new wkt::FieldMask(),
            };
            IndexEndpoint expectedResponse = new IndexEndpoint
            {
                IndexEndpointName = IndexEndpointName.FromProjectLocationIndexEndpoint("[PROJECT]", "[LOCATION]", "[INDEX_ENDPOINT]"),
                DisplayName       = "display_name137f65c2",
                Description       = "description2cf9da67",
                DeployedIndexes   =
                {
                    new DeployedIndex(),
                },
                Etag   = "etage8ad7218",
                Labels =
                {
                    {
                        "key8a0b6e3c",
                        "value60c16320"
                    },
                },
                CreateTime = new wkt::Timestamp(),
                UpdateTime = new wkt::Timestamp(),
                Network    = "networkd22ce091",
                EnablePrivateServiceConnect = false,
            };

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

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            IndexEndpoint responseCancellationToken = await client.UpdateIndexEndpointAsync(request.IndexEndpoint, request.UpdateMask, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
        public void UpdateIndexEndpoint()
        {
            moq::Mock <IndexEndpointService.IndexEndpointServiceClient> mockGrpcClient = new moq::Mock <IndexEndpointService.IndexEndpointServiceClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            UpdateIndexEndpointRequest request = new UpdateIndexEndpointRequest
            {
                IndexEndpoint = new IndexEndpoint(),
                UpdateMask    = new wkt::FieldMask(),
            };
            IndexEndpoint expectedResponse = new IndexEndpoint
            {
                IndexEndpointName = IndexEndpointName.FromProjectLocationIndexEndpoint("[PROJECT]", "[LOCATION]", "[INDEX_ENDPOINT]"),
                DisplayName       = "display_name137f65c2",
                Description       = "description2cf9da67",
                DeployedIndexes   =
                {
                    new DeployedIndex(),
                },
                Etag   = "etage8ad7218",
                Labels =
                {
                    {
                        "key8a0b6e3c",
                        "value60c16320"
                    },
                },
                CreateTime = new wkt::Timestamp(),
                UpdateTime = new wkt::Timestamp(),
                Network    = "networkd22ce091",
            };

            mockGrpcClient.Setup(x => x.UpdateIndexEndpoint(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            IndexEndpointServiceClient client = new IndexEndpointServiceClientImpl(mockGrpcClient.Object, null);
            IndexEndpoint response            = client.UpdateIndexEndpoint(request.IndexEndpoint, request.UpdateMask);

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