public async stt::Task GetConnectorRequestObjectAsync() { moq::Mock <VpcAccessService.VpcAccessServiceClient> mockGrpcClient = new moq::Mock <VpcAccessService.VpcAccessServiceClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); GetConnectorRequest request = new GetConnectorRequest { ConnectorName = ConnectorName.FromProjectLocationConnector("[PROJECT]", "[LOCATION]", "[CONNECTOR]"), }; Connector expectedResponse = new Connector { ConnectorName = ConnectorName.FromProjectLocationConnector("[PROJECT]", "[LOCATION]", "[CONNECTOR]"), Network = "networkd22ce091", IpCidrRange = "ip_cidr_range745a04d3", State = Connector.Types.State.Unspecified, MinThroughput = -1306078102, MaxThroughput = 1609945563, ConnectedProjects = { "connected_projects7e2fb014", }, Subnet = new Connector.Types.Subnet(), }; mockGrpcClient.Setup(x => x.GetConnectorAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Connector>(stt::Task.FromResult(expectedResponse), null, null, null, null)); VpcAccessServiceClient client = new VpcAccessServiceClientImpl(mockGrpcClient.Object, null); Connector responseCallSettings = await client.GetConnectorAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); Connector responseCancellationToken = await client.GetConnectorAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public void GetConnector() { moq::Mock <VpcAccessService.VpcAccessServiceClient> mockGrpcClient = new moq::Mock <VpcAccessService.VpcAccessServiceClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); GetConnectorRequest request = new GetConnectorRequest { ConnectorName = ConnectorName.FromProjectLocationConnector("[PROJECT]", "[LOCATION]", "[CONNECTOR]"), }; Connector expectedResponse = new Connector { ConnectorName = ConnectorName.FromProjectLocationConnector("[PROJECT]", "[LOCATION]", "[CONNECTOR]"), Network = "networkd22ce091", IpCidrRange = "ip_cidr_range745a04d3", State = Connector.Types.State.Unspecified, MinThroughput = -1306078102, MaxThroughput = 1609945563, ConnectedProjects = { "connected_projects7e2fb014", }, Subnet = new Connector.Types.Subnet(), }; mockGrpcClient.Setup(x => x.GetConnector(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); VpcAccessServiceClient client = new VpcAccessServiceClientImpl(mockGrpcClient.Object, null); Connector response = client.GetConnector(request.Name); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
/// <summary>Snippet for GetConnector</summary> public void GetConnectorRequestObject() { // Snippet: GetConnector(GetConnectorRequest, CallSettings) // Create client VpcAccessServiceClient vpcAccessServiceClient = VpcAccessServiceClient.Create(); // Initialize request argument(s) GetConnectorRequest request = new GetConnectorRequest { ConnectorName = ConnectorName.FromProjectLocationConnector("[PROJECT]", "[LOCATION]", "[CONNECTOR]"), }; // Make the request Connector response = vpcAccessServiceClient.GetConnector(request); // End snippet }
/// <summary>Snippet for GetConnectorAsync</summary> public async Task GetConnectorRequestObjectAsync() { // Snippet: GetConnectorAsync(GetConnectorRequest, CallSettings) // Additional: GetConnectorAsync(GetConnectorRequest, CancellationToken) // Create client VpcAccessServiceClient vpcAccessServiceClient = await VpcAccessServiceClient.CreateAsync(); // Initialize request argument(s) GetConnectorRequest request = new GetConnectorRequest { ConnectorName = ConnectorName.FromProjectLocationConnector("[PROJECT]", "[LOCATION]", "[CONNECTOR]"), }; // Make the request Connector response = await vpcAccessServiceClient.GetConnectorAsync(request); // End snippet }
public async Task <ActionResult> Get([FromRoute] GetConnectorRequest request) { var command = new GetIntIdEntityCommand <Connector, ConnectorDto>() { DtoFactory = ConnectorDto.From, Request = request }; var result = await getIntIdEntityHandler.HandleAsync(command); if (!result.IsSuccess) { ModelState.AddModelError(Constants.ModelState.ErrorsProperty, result.Messages); return(BadRequest(ModelState)); } return(Ok(result.Value)); }