public async stt::Task GetAdGroupFeedRequestObjectAsync() { moq::Mock <AdGroupFeedService.AdGroupFeedServiceClient> mockGrpcClient = new moq::Mock <AdGroupFeedService.AdGroupFeedServiceClient>(moq::MockBehavior.Strict); GetAdGroupFeedRequest request = new GetAdGroupFeedRequest { ResourceNameAsAdGroupFeedName = gagvr::AdGroupFeedName.FromCustomerAdGroupFeed("[CUSTOMER_ID]", "[AD_GROUP_ID]", "[FEED_ID]"), }; gagvr::AdGroupFeed expectedResponse = new gagvr::AdGroupFeed { ResourceNameAsAdGroupFeedName = gagvr::AdGroupFeedName.FromCustomerAdGroupFeed("[CUSTOMER_ID]", "[AD_GROUP_ID]", "[FEED_ID]"), PlaceholderTypes = { gagve::PlaceholderTypeEnum.Types.PlaceholderType.AdCustomizer, }, MatchingFunction = new gagvc::MatchingFunction(), Status = gagve::FeedLinkStatusEnum.Types.FeedLinkStatus.Enabled, FeedAsFeedName = gagvr::FeedName.FromCustomerFeed("[CUSTOMER_ID]", "[FEED_ID]"), AdGroupAsAdGroupName = gagvr::AdGroupName.FromCustomerAdGroup("[CUSTOMER_ID]", "[AD_GROUP_ID]"), }; mockGrpcClient.Setup(x => x.GetAdGroupFeedAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <gagvr::AdGroupFeed>(stt::Task.FromResult(expectedResponse), null, null, null, null)); AdGroupFeedServiceClient client = new AdGroupFeedServiceClientImpl(mockGrpcClient.Object, null); gagvr::AdGroupFeed responseCallSettings = await client.GetAdGroupFeedAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); gagvr::AdGroupFeed responseCancellationToken = await client.GetAdGroupFeedAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public async Task GetAdGroupFeedAsync2() { Mock <AdGroupFeedService.AdGroupFeedServiceClient> mockGrpcClient = new Mock <AdGroupFeedService.AdGroupFeedServiceClient>(MockBehavior.Strict); GetAdGroupFeedRequest request = new GetAdGroupFeedRequest { ResourceName = new AdGroupFeedName("[CUSTOMER]", "[AD_GROUP_FEED]").ToString(), }; AdGroupFeed expectedResponse = new AdGroupFeed { ResourceName = "resourceName2625949903", }; mockGrpcClient.Setup(x => x.GetAdGroupFeedAsync(request, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <AdGroupFeed>(Task.FromResult(expectedResponse), null, null, null, null)); AdGroupFeedServiceClient client = new AdGroupFeedServiceClientImpl(mockGrpcClient.Object, null); AdGroupFeed response = await client.GetAdGroupFeedAsync(request); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }