Beispiel #1
0
        public async stt::Task GetCampaignAudienceViewAsync()
        {
            moq::Mock <CampaignAudienceViewService.CampaignAudienceViewServiceClient> mockGrpcClient = new moq::Mock <CampaignAudienceViewService.CampaignAudienceViewServiceClient>(moq::MockBehavior.Strict);
            GetCampaignAudienceViewRequest request = new GetCampaignAudienceViewRequest
            {
                ResourceNameAsCampaignAudienceViewName = gagvr::CampaignAudienceViewName.FromCustomerCampaignAudienceView("[CUSTOMER]", "[CAMPAIGN_AUDIENCE_VIEW]"),
            };
            gagvr::CampaignAudienceView expectedResponse = new gagvr::CampaignAudienceView
            {
                ResourceNameAsCampaignAudienceViewName = gagvr::CampaignAudienceViewName.FromCustomerCampaignAudienceView("[CUSTOMER]", "[CAMPAIGN_AUDIENCE_VIEW]"),
            };

            mockGrpcClient.Setup(x => x.GetCampaignAudienceViewAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <gagvr::CampaignAudienceView>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            CampaignAudienceViewServiceClient client = new CampaignAudienceViewServiceClientImpl(mockGrpcClient.Object, null);
            gagvr::CampaignAudienceView       responseCallSettings = await client.GetCampaignAudienceViewAsync(request.ResourceName, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            Assert.AreEqual(expectedResponse, responseCallSettings);
            gagvr::CampaignAudienceView responseCancellationToken = await client.GetCampaignAudienceViewAsync(request.ResourceName, st::CancellationToken.None);

            Assert.AreEqual(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
        public async Task GetCampaignAudienceViewAsync2()
        {
            Mock <CampaignAudienceViewService.CampaignAudienceViewServiceClient> mockGrpcClient = new Mock <CampaignAudienceViewService.CampaignAudienceViewServiceClient>(MockBehavior.Strict);
            GetCampaignAudienceViewRequest request = new GetCampaignAudienceViewRequest
            {
                ResourceName = new CampaignAudienceViewName("[CUSTOMER]", "[CAMPAIGN_AUDIENCE_VIEW]").ToString(),
            };
            CampaignAudienceView expectedResponse = new CampaignAudienceView
            {
                ResourceName = "resourceName2625949903",
            };

            mockGrpcClient.Setup(x => x.GetCampaignAudienceViewAsync(request, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <CampaignAudienceView>(Task.FromResult(expectedResponse), null, null, null, null));
            CampaignAudienceViewServiceClient client = new CampaignAudienceViewServiceClientImpl(mockGrpcClient.Object, null);
            CampaignAudienceView response            = await client.GetCampaignAudienceViewAsync(request);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }