public async stt::Task GetAdParameterRequestObjectAsync() { moq::Mock <AdParameterService.AdParameterServiceClient> mockGrpcClient = new moq::Mock <AdParameterService.AdParameterServiceClient>(moq::MockBehavior.Strict); GetAdParameterRequest request = new GetAdParameterRequest { ResourceNameAsAdParameterName = gagvr::AdParameterName.FromCustomerAdGroupCriterionParameterIndex("[CUSTOMER_ID]", "[AD_GROUP_ID]", "[CRITERION_ID]", "[PARAMETER_INDEX]"), }; gagvr::AdParameter expectedResponse = new gagvr::AdParameter { ResourceNameAsAdParameterName = gagvr::AdParameterName.FromCustomerAdGroupCriterionParameterIndex("[CUSTOMER_ID]", "[AD_GROUP_ID]", "[CRITERION_ID]", "[PARAMETER_INDEX]"), AdGroupCriterionAsAdGroupCriterionName = gagvr::AdGroupCriterionName.FromCustomerAdGroupCriterion("[CUSTOMER_ID]", "[AD_GROUP_ID]", "[CRITERION_ID]"), ParameterIndex = 2776974389611536835L, InsertionText = "insertion_text562a41ad", }; mockGrpcClient.Setup(x => x.GetAdParameterAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <gagvr::AdParameter>(stt::Task.FromResult(expectedResponse), null, null, null, null)); AdParameterServiceClient client = new AdParameterServiceClientImpl(mockGrpcClient.Object, null); gagvr::AdParameter responseCallSettings = await client.GetAdParameterAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); gagvr::AdParameter responseCancellationToken = await client.GetAdParameterAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public async Task GetAdParameterAsync2() { Mock <AdParameterService.AdParameterServiceClient> mockGrpcClient = new Mock <AdParameterService.AdParameterServiceClient>(MockBehavior.Strict); GetAdParameterRequest request = new GetAdParameterRequest { ResourceName = new AdParameterName("[CUSTOMER]", "[AD_PARAMETER]").ToString(), }; AdParameter expectedResponse = new AdParameter { ResourceName = "resourceName2625949903", }; mockGrpcClient.Setup(x => x.GetAdParameterAsync(request, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <AdParameter>(Task.FromResult(expectedResponse), null, null, null, null)); AdParameterServiceClient client = new AdParameterServiceClientImpl(mockGrpcClient.Object, null); AdParameter response = await client.GetAdParameterAsync(request); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }