Ejemplo n.º 1
0
        public void GetAdGroupAudienceView()
        {
            moq::Mock <AdGroupAudienceViewService.AdGroupAudienceViewServiceClient> mockGrpcClient = new moq::Mock <AdGroupAudienceViewService.AdGroupAudienceViewServiceClient>(moq::MockBehavior.Strict);
            GetAdGroupAudienceViewRequest request = new GetAdGroupAudienceViewRequest
            {
                ResourceNameAsAdGroupAudienceViewName = gagvr::AdGroupAudienceViewName.FromCustomerAdGroupAudienceView("[CUSTOMER]", "[AD_GROUP_AUDIENCE_VIEW]"),
            };
            gagvr::AdGroupAudienceView expectedResponse = new gagvr::AdGroupAudienceView
            {
                ResourceNameAsAdGroupAudienceViewName = gagvr::AdGroupAudienceViewName.FromCustomerAdGroupAudienceView("[CUSTOMER]", "[AD_GROUP_AUDIENCE_VIEW]"),
            };

            mockGrpcClient.Setup(x => x.GetAdGroupAudienceView(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            AdGroupAudienceViewServiceClient client   = new AdGroupAudienceViewServiceClientImpl(mockGrpcClient.Object, null);
            gagvr::AdGroupAudienceView       response = client.GetAdGroupAudienceView(request.ResourceName);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        public void GetAdGroupAudienceView2()
        {
            Mock <AdGroupAudienceViewService.AdGroupAudienceViewServiceClient> mockGrpcClient = new Mock <AdGroupAudienceViewService.AdGroupAudienceViewServiceClient>(MockBehavior.Strict);
            GetAdGroupAudienceViewRequest request = new GetAdGroupAudienceViewRequest
            {
                ResourceName = new AdGroupAudienceViewName("[CUSTOMER]", "[AD_GROUP_AUDIENCE_VIEW]").ToString(),
            };
            AdGroupAudienceView expectedResponse = new AdGroupAudienceView
            {
                ResourceName = "resourceName2625949903",
            };

            mockGrpcClient.Setup(x => x.GetAdGroupAudienceView(request, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            AdGroupAudienceViewServiceClient client = new AdGroupAudienceViewServiceClientImpl(mockGrpcClient.Object, null);
            AdGroupAudienceView response            = client.GetAdGroupAudienceView(request);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        public async Task GetAdGroupAudienceViewAsync()
        {
            Mock <AdGroupAudienceViewService.AdGroupAudienceViewServiceClient> mockGrpcClient = new Mock <AdGroupAudienceViewService.AdGroupAudienceViewServiceClient>(MockBehavior.Strict);
            GetAdGroupAudienceViewRequest expectedRequest = new GetAdGroupAudienceViewRequest
            {
                ResourceName = new AdGroupAudienceViewName("[CUSTOMER]", "[AD_GROUP_AUDIENCE_VIEW]").ToString(),
            };
            AdGroupAudienceView expectedResponse = new AdGroupAudienceView
            {
                ResourceName = "resourceName2625949903",
            };

            mockGrpcClient.Setup(x => x.GetAdGroupAudienceViewAsync(expectedRequest, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <AdGroupAudienceView>(Task.FromResult(expectedResponse), null, null, null, null));
            AdGroupAudienceViewServiceClient client = new AdGroupAudienceViewServiceClientImpl(mockGrpcClient.Object, null);
            string formattedResourceName            = new AdGroupAudienceViewName("[CUSTOMER]", "[AD_GROUP_AUDIENCE_VIEW]").ToString();
            AdGroupAudienceView response            = await client.GetAdGroupAudienceViewAsync(formattedResourceName);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Ejemplo n.º 4
0
        public async stt::Task GetAdGroupAudienceViewAsync()
        {
            moq::Mock <AdGroupAudienceViewService.AdGroupAudienceViewServiceClient> mockGrpcClient = new moq::Mock <AdGroupAudienceViewService.AdGroupAudienceViewServiceClient>(moq::MockBehavior.Strict);
            GetAdGroupAudienceViewRequest request = new GetAdGroupAudienceViewRequest
            {
                ResourceNameAsAdGroupAudienceViewName = gagvr::AdGroupAudienceViewName.FromCustomerAdGroupAudienceView("[CUSTOMER]", "[AD_GROUP_AUDIENCE_VIEW]"),
            };
            gagvr::AdGroupAudienceView expectedResponse = new gagvr::AdGroupAudienceView
            {
                ResourceNameAsAdGroupAudienceViewName = gagvr::AdGroupAudienceViewName.FromCustomerAdGroupAudienceView("[CUSTOMER]", "[AD_GROUP_AUDIENCE_VIEW]"),
            };

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

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            gagvr::AdGroupAudienceView responseCancellationToken = await client.GetAdGroupAudienceViewAsync(request.ResourceName, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }