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 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(); }
public async stt::Task GetNodeRequestObjectAsync() { 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); GetNodeRequest request = new GetNodeRequest { NodeName = NodeName.FromProjectLocationNode("[PROJECT]", "[LOCATION]", "[NODE]"), }; Node expectedResponse = new Node { NodeName = NodeName.FromProjectLocationNode("[PROJECT]", "[LOCATION]", "[NODE]"), Description = "description2cf9da67", AcceleratorType = "accelerator_type68a25f42", #pragma warning disable CS0612 IpAddress = "ip_address46a72553", #pragma warning restore CS0612 State = Node.Types.State.Restarting, HealthDescription = "health_descriptionb522cddb", TensorflowVersion = "tensorflow_version878dc75b", Network = "networkd22ce091", CidrBlock = "cidr_block0fc04814", #pragma warning disable CS0612 Port = "portfb551590", #pragma warning restore CS0612 ServiceAccount = "service_accounta3c1b923", CreateTime = new wkt::Timestamp(), SchedulingConfig = new SchedulingConfig(), NetworkEndpoints = { new NetworkEndpoint(), }, Health = Node.Types.Health.UnhealthyMaintenance, Labels = { { "key8a0b6e3c", "value60c16320" }, }, UseServiceNetworking = true, ApiVersion = Node.Types.ApiVersion.V2Alpha1, Symptoms = { new Symptom(), }, }; mockGrpcClient.Setup(x => x.GetNodeAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Node>(stt::Task.FromResult(expectedResponse), null, null, null, null)); TpuClient client = new TpuClientImpl(mockGrpcClient.Object, null); Node responseCallSettings = await client.GetNodeAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); Node responseCancellationToken = await client.GetNodeAsync(request, 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(); }
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(); }