Ejemplo n.º 1
0
        public async stt::Task GetTensorFlowVersionResourceNamesAsync()
        {
            moq::Mock <Tpu.TpuClient> mockGrpcClient = new moq::Mock <Tpu.TpuClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetTensorFlowVersionRequest request = new GetTensorFlowVersionRequest
            {
                TensorFlowVersionName = TensorFlowVersionName.FromProjectLocationTensorFlowVersion("[PROJECT]", "[LOCATION]", "[TENSOR_FLOW_VERSION]"),
            };
            TensorFlowVersion expectedResponse = new TensorFlowVersion
            {
                TensorFlowVersionName = TensorFlowVersionName.FromProjectLocationTensorFlowVersion("[PROJECT]", "[LOCATION]", "[TENSOR_FLOW_VERSION]"),
                Version = "version102ff72a",
            };

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

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            TensorFlowVersion responseCancellationToken = await client.GetTensorFlowVersionAsync(request.TensorFlowVersionName, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Ejemplo n.º 2
0
        public void GetTensorFlowVersionResourceNames()
        {
            moq::Mock <Tpu.TpuClient> mockGrpcClient = new moq::Mock <Tpu.TpuClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetTensorFlowVersionRequest request = new GetTensorFlowVersionRequest
            {
                TensorFlowVersionName = TensorFlowVersionName.FromProjectLocationTensorFlowVersion("[PROJECT]", "[LOCATION]", "[TENSOR_FLOW_VERSION]"),
            };
            TensorFlowVersion expectedResponse = new TensorFlowVersion
            {
                TensorFlowVersionName = TensorFlowVersionName.FromProjectLocationTensorFlowVersion("[PROJECT]", "[LOCATION]", "[TENSOR_FLOW_VERSION]"),
                Version = "version102ff72a",
            };

            mockGrpcClient.Setup(x => x.GetTensorFlowVersion(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            TpuClient         client   = new TpuClientImpl(mockGrpcClient.Object, null);
            TensorFlowVersion response = client.GetTensorFlowVersion(request.TensorFlowVersionName);

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