Esempio n. 1
0
        public async stt::Task GetFeedMappingRequestObjectAsync()
        {
            moq::Mock <FeedMappingService.FeedMappingServiceClient> mockGrpcClient = new moq::Mock <FeedMappingService.FeedMappingServiceClient>(moq::MockBehavior.Strict);
            GetFeedMappingRequest request = new GetFeedMappingRequest
            {
                ResourceNameAsFeedMappingName = gagvr::FeedMappingName.FromCustomerFeedMapping("[CUSTOMER]", "[FEED_MAPPING]"),
            };
            gagvr::FeedMapping expectedResponse = new gagvr::FeedMapping
            {
                ResourceNameAsFeedMappingName = gagvr::FeedMappingName.FromCustomerFeedMapping("[CUSTOMER]", "[FEED_MAPPING]"),
                FeedAsFeedName         = gagvr::FeedName.FromCustomerFeed("[CUSTOMER]", "[FEED]"),
                PlaceholderType        = gagve::PlaceholderTypeEnum.Types.PlaceholderType.Message,
                CriterionType          = gagve::FeedMappingCriterionTypeEnum.Types.FeedMappingCriterionType.Unknown,
                AttributeFieldMappings =
                {
                    new gagvr::AttributeFieldMapping(),
                },
                Status = gagve::FeedMappingStatusEnum.Types.FeedMappingStatus.Enabled,
            };

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

            Assert.AreEqual(expectedResponse, responseCallSettings);
            gagvr::FeedMapping responseCancellationToken = await client.GetFeedMappingAsync(request, st::CancellationToken.None);

            Assert.AreEqual(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Esempio n. 2
0
        public async Task GetFeedMappingAsync2()
        {
            Mock <FeedMappingService.FeedMappingServiceClient> mockGrpcClient = new Mock <FeedMappingService.FeedMappingServiceClient>(MockBehavior.Strict);
            GetFeedMappingRequest request = new GetFeedMappingRequest
            {
                ResourceName = new FeedMappingName("[CUSTOMER]", "[FEED_MAPPING]").ToString(),
            };
            FeedMapping expectedResponse = new FeedMapping
            {
                ResourceName = "resourceName2625949903",
            };

            mockGrpcClient.Setup(x => x.GetFeedMappingAsync(request, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <FeedMapping>(Task.FromResult(expectedResponse), null, null, null, null));
            FeedMappingServiceClient client = new FeedMappingServiceClientImpl(mockGrpcClient.Object, null);
            FeedMapping response            = await client.GetFeedMappingAsync(request);

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