public void GetFeedRequestObject() { moq::Mock <FeedService.FeedServiceClient> mockGrpcClient = new moq::Mock <FeedService.FeedServiceClient>(moq::MockBehavior.Strict); GetFeedRequest request = new GetFeedRequest { ResourceNameAsFeedName = gagvr::FeedName.FromCustomerFeed("[CUSTOMER_ID]", "[FEED_ID]"), }; gagvr::Feed expectedResponse = new gagvr::Feed { ResourceNameAsFeedName = gagvr::FeedName.FromCustomerFeed("[CUSTOMER_ID]", "[FEED_ID]"), Attributes = { new gagvr::FeedAttribute(), }, Origin = gagve::FeedOriginEnum.Types.FeedOrigin.Unspecified, PlacesLocationFeedData = new gagvr::Feed.Types.PlacesLocationFeedData(), AffiliateLocationFeedData = new gagvr::Feed.Types.AffiliateLocationFeedData(), Status = gagve::FeedStatusEnum.Types.FeedStatus.Enabled, AttributeOperations = { new gagvr::FeedAttributeOperation(), }, Id = -6774108720365892680L, FeedName = gagvr::FeedName.FromCustomerFeed("[CUSTOMER_ID]", "[FEED_ID]"), }; mockGrpcClient.Setup(x => x.GetFeed(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); FeedServiceClient client = new FeedServiceClientImpl(mockGrpcClient.Object, null); gagvr::Feed response = client.GetFeed(request); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async stt::Task GetFeedRequestObjectAsync() { moq::Mock <FeedService.FeedServiceClient> mockGrpcClient = new moq::Mock <FeedService.FeedServiceClient>(moq::MockBehavior.Strict); GetFeedRequest request = new GetFeedRequest { ResourceNameAsFeedName = gagvr::FeedName.FromCustomerFeed("[CUSTOMER_ID]", "[FEED_ID]"), }; gagvr::Feed expectedResponse = new gagvr::Feed { ResourceNameAsFeedName = gagvr::FeedName.FromCustomerFeed("[CUSTOMER_ID]", "[FEED_ID]"), Attributes = { new gagvr::FeedAttribute(), }, Origin = gagve::FeedOriginEnum.Types.FeedOrigin.Unspecified, PlacesLocationFeedData = new gagvr::Feed.Types.PlacesLocationFeedData(), AffiliateLocationFeedData = new gagvr::Feed.Types.AffiliateLocationFeedData(), Status = gagve::FeedStatusEnum.Types.FeedStatus.Enabled, AttributeOperations = { new gagvr::FeedAttributeOperation(), }, Id = -6774108720365892680L, FeedName = gagvr::FeedName.FromCustomerFeed("[CUSTOMER_ID]", "[FEED_ID]"), }; mockGrpcClient.Setup(x => x.GetFeedAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <gagvr::Feed>(stt::Task.FromResult(expectedResponse), null, null, null, null)); FeedServiceClient client = new FeedServiceClientImpl(mockGrpcClient.Object, null); gagvr::Feed responseCallSettings = await client.GetFeedAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); gagvr::Feed responseCancellationToken = await client.GetFeedAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }