示例#1
0
        public void MutateAds()
        {
            moq::Mock <AdService.AdServiceClient> mockGrpcClient = new moq::Mock <AdService.AdServiceClient>(moq::MockBehavior.Strict);
            MutateAdsRequest request = new MutateAdsRequest
            {
                CustomerId = "customer_id3b3724cb",
                Operations = { new AdOperation(), },
            };
            MutateAdsResponse expectedResponse = new MutateAdsResponse
            {
                Results =
                {
                    new MutateAdResult(),
                },
            };

            mockGrpcClient.Setup(x => x.MutateAds(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            AdServiceClient   client   = new AdServiceClientImpl(mockGrpcClient.Object, null);
            MutateAdsResponse response = client.MutateAds(request.CustomerId, request.Operations);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        public void MutateAdsRequestObject()
        {
            moq::Mock <AdService.AdServiceClient> mockGrpcClient = new moq::Mock <AdService.AdServiceClient>(moq::MockBehavior.Strict);
            MutateAdsRequest request = new MutateAdsRequest
            {
                CustomerId          = "customer_id3b3724cb",
                Operations          = { new AdOperation(), },
                ResponseContentType = gagve::ResponseContentTypeEnum.Types.ResponseContentType.ResourceNameOnly,
            };
            MutateAdsResponse expectedResponse = new MutateAdsResponse
            {
                Results =
                {
                    new MutateAdResult(),
                },
            };

            mockGrpcClient.Setup(x => x.MutateAds(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            AdServiceClient   client   = new AdServiceClientImpl(mockGrpcClient.Object, null);
            MutateAdsResponse response = client.MutateAds(request);

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