public void GetDetailedDemographic() { moq::Mock <DetailedDemographicService.DetailedDemographicServiceClient> mockGrpcClient = new moq::Mock <DetailedDemographicService.DetailedDemographicServiceClient>(moq::MockBehavior.Strict); GetDetailedDemographicRequest request = new GetDetailedDemographicRequest { ResourceNameAsDetailedDemographicName = gagvr::DetailedDemographicName.FromCustomerDetailedDemographic("[CUSTOMER_ID]", "[DETAILED_DEMOGRAPHIC_ID]"), }; gagvr::DetailedDemographic expectedResponse = new gagvr::DetailedDemographic { ResourceNameAsDetailedDemographicName = gagvr::DetailedDemographicName.FromCustomerDetailedDemographic("[CUSTOMER_ID]", "[DETAILED_DEMOGRAPHIC_ID]"), Id = -6774108720365892680L, DetailedDemographicName = gagvr::DetailedDemographicName.FromCustomerDetailedDemographic("[CUSTOMER_ID]", "[DETAILED_DEMOGRAPHIC_ID]"), ParentAsDetailedDemographicName = gagvr::DetailedDemographicName.FromCustomerDetailedDemographic("[CUSTOMER_ID]", "[DETAILED_DEMOGRAPHIC_ID]"), LaunchedToAll = true, Availabilities = { new gagvc::CriterionCategoryAvailability(), }, }; mockGrpcClient.Setup(x => x.GetDetailedDemographic(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); DetailedDemographicServiceClient client = new DetailedDemographicServiceClientImpl(mockGrpcClient.Object, null); gagvr::DetailedDemographic response = client.GetDetailedDemographic(request.ResourceName); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async stt::Task GetDetailedDemographicRequestObjectAsync() { moq::Mock <DetailedDemographicService.DetailedDemographicServiceClient> mockGrpcClient = new moq::Mock <DetailedDemographicService.DetailedDemographicServiceClient>(moq::MockBehavior.Strict); GetDetailedDemographicRequest request = new GetDetailedDemographicRequest { ResourceNameAsDetailedDemographicName = gagvr::DetailedDemographicName.FromCustomerDetailedDemographic("[CUSTOMER_ID]", "[DETAILED_DEMOGRAPHIC_ID]"), }; gagvr::DetailedDemographic expectedResponse = new gagvr::DetailedDemographic { ResourceNameAsDetailedDemographicName = gagvr::DetailedDemographicName.FromCustomerDetailedDemographic("[CUSTOMER_ID]", "[DETAILED_DEMOGRAPHIC_ID]"), Id = -6774108720365892680L, DetailedDemographicName = gagvr::DetailedDemographicName.FromCustomerDetailedDemographic("[CUSTOMER_ID]", "[DETAILED_DEMOGRAPHIC_ID]"), ParentAsDetailedDemographicName = gagvr::DetailedDemographicName.FromCustomerDetailedDemographic("[CUSTOMER_ID]", "[DETAILED_DEMOGRAPHIC_ID]"), LaunchedToAll = true, Availabilities = { new gagvc::CriterionCategoryAvailability(), }, }; mockGrpcClient.Setup(x => x.GetDetailedDemographicAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <gagvr::DetailedDemographic>(stt::Task.FromResult(expectedResponse), null, null, null, null)); DetailedDemographicServiceClient client = new DetailedDemographicServiceClientImpl(mockGrpcClient.Object, null); gagvr::DetailedDemographic responseCallSettings = await client.GetDetailedDemographicAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); Assert.AreEqual(expectedResponse, responseCallSettings); gagvr::DetailedDemographic responseCancellationToken = await client.GetDetailedDemographicAsync(request, st::CancellationToken.None); Assert.AreEqual(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
/// <summary>Snippet for GetDetailedDemographic</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void GetDetailedDemographicRequestObject() { // Create client DetailedDemographicServiceClient detailedDemographicServiceClient = DetailedDemographicServiceClient.Create(); // Initialize request argument(s) GetDetailedDemographicRequest request = new GetDetailedDemographicRequest { ResourceNameAsDetailedDemographicName = DetailedDemographicName.FromCustomerDetailedDemographic("[CUSTOMER_ID]", "[DETAILED_DEMOGRAPHIC_ID]"), }; // Make the request DetailedDemographic response = detailedDemographicServiceClient.GetDetailedDemographic(request); }
/// <summary>Snippet for GetDetailedDemographicAsync</summary> public async Task GetDetailedDemographicRequestObjectAsync() { // Snippet: GetDetailedDemographicAsync(GetDetailedDemographicRequest, CallSettings) // Additional: GetDetailedDemographicAsync(GetDetailedDemographicRequest, CancellationToken) // Create client DetailedDemographicServiceClient detailedDemographicServiceClient = await DetailedDemographicServiceClient.CreateAsync(); // Initialize request argument(s) GetDetailedDemographicRequest request = new GetDetailedDemographicRequest { ResourceNameAsDetailedDemographicName = DetailedDemographicName.FromCustomerDetailedDemographic("[CUSTOMER_ID]", "[DETAILED_DEMOGRAPHIC_ID]"), }; // Make the request DetailedDemographic response = await detailedDemographicServiceClient.GetDetailedDemographicAsync(request); // End snippet }