public async stt::Task GetAcceleratorTypeResourceNamesAsync() { 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); GetAcceleratorTypeRequest request = new GetAcceleratorTypeRequest { AcceleratorTypeName = AcceleratorTypeName.FromProjectLocationAcceleratorType("[PROJECT]", "[LOCATION]", "[ACCELERATOR_TYPE]"), }; AcceleratorType expectedResponse = new AcceleratorType { AcceleratorTypeName = AcceleratorTypeName.FromProjectLocationAcceleratorType("[PROJECT]", "[LOCATION]", "[ACCELERATOR_TYPE]"), Type = "typee2cc9d59", }; mockGrpcClient.Setup(x => x.GetAcceleratorTypeAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <AcceleratorType>(stt::Task.FromResult(expectedResponse), null, null, null, null)); TpuClient client = new TpuClientImpl(mockGrpcClient.Object, null); AcceleratorType responseCallSettings = await client.GetAcceleratorTypeAsync(request.AcceleratorTypeName, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); AcceleratorType responseCancellationToken = await client.GetAcceleratorTypeAsync(request.AcceleratorTypeName, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public void GetAcceleratorTypeResourceNames() { 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); GetAcceleratorTypeRequest request = new GetAcceleratorTypeRequest { AcceleratorTypeName = AcceleratorTypeName.FromProjectLocationAcceleratorType("[PROJECT]", "[LOCATION]", "[ACCELERATOR_TYPE]"), }; AcceleratorType expectedResponse = new AcceleratorType { AcceleratorTypeName = AcceleratorTypeName.FromProjectLocationAcceleratorType("[PROJECT]", "[LOCATION]", "[ACCELERATOR_TYPE]"), Type = "typee2cc9d59", }; mockGrpcClient.Setup(x => x.GetAcceleratorType(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); TpuClient client = new TpuClientImpl(mockGrpcClient.Object, null); AcceleratorType response = client.GetAcceleratorType(request.AcceleratorTypeName); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }