예제 #1
0
        public void GetCampaignLabelRequestObject()
        {
            moq::Mock <CampaignLabelService.CampaignLabelServiceClient> mockGrpcClient = new moq::Mock <CampaignLabelService.CampaignLabelServiceClient>(moq::MockBehavior.Strict);
            GetCampaignLabelRequest request = new GetCampaignLabelRequest
            {
                ResourceNameAsCampaignLabelName = gagvr::CampaignLabelName.FromCustomerCampaignLabel("[CUSTOMER_ID]", "[CAMPAIGN_ID]", "[LABEL_ID]"),
            };
            gagvr::CampaignLabel expectedResponse = new gagvr::CampaignLabel
            {
                ResourceNameAsCampaignLabelName = gagvr::CampaignLabelName.FromCustomerCampaignLabel("[CUSTOMER_ID]", "[CAMPAIGN_ID]", "[LABEL_ID]"),
                CampaignAsCampaignName          = gagvr::CampaignName.FromCustomerCampaign("[CUSTOMER_ID]", "[CAMPAIGN_ID]"),
                LabelAsLabelName = gagvr::LabelName.FromCustomerLabel("[CUSTOMER_ID]", "[LABEL_ID]"),
            };

            mockGrpcClient.Setup(x => x.GetCampaignLabel(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            CampaignLabelServiceClient client   = new CampaignLabelServiceClientImpl(mockGrpcClient.Object, null);
            gagvr::CampaignLabel       response = client.GetCampaignLabel(request);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
예제 #2
0
        public async Task GetCampaignLabelAsync()
        {
            Mock <CampaignLabelService.CampaignLabelServiceClient> mockGrpcClient = new Mock <CampaignLabelService.CampaignLabelServiceClient>(MockBehavior.Strict);
            GetCampaignLabelRequest expectedRequest = new GetCampaignLabelRequest
            {
                ResourceName = new CampaignLabelName("[CUSTOMER]", "[CAMPAIGN_LABEL]").ToString(),
            };
            CampaignLabel expectedResponse = new CampaignLabel
            {
                ResourceName = "resourceName2625949903",
            };

            mockGrpcClient.Setup(x => x.GetCampaignLabelAsync(expectedRequest, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <CampaignLabel>(Task.FromResult(expectedResponse), null, null, null, null));
            CampaignLabelServiceClient client   = new CampaignLabelServiceClientImpl(mockGrpcClient.Object, null);
            string        formattedResourceName = new CampaignLabelName("[CUSTOMER]", "[CAMPAIGN_LABEL]").ToString();
            CampaignLabel response = await client.GetCampaignLabelAsync(formattedResourceName);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
예제 #3
0
        public async stt::Task GetCampaignLabelRequestObjectAsync()
        {
            moq::Mock <CampaignLabelService.CampaignLabelServiceClient> mockGrpcClient = new moq::Mock <CampaignLabelService.CampaignLabelServiceClient>(moq::MockBehavior.Strict);
            GetCampaignLabelRequest request = new GetCampaignLabelRequest
            {
                ResourceNameAsCampaignLabelName = gagvr::CampaignLabelName.FromCustomerCampaignLabel("[CUSTOMER]", "[CAMPAIGN_LABEL]"),
            };
            gagvr::CampaignLabel expectedResponse = new gagvr::CampaignLabel
            {
                ResourceNameAsCampaignLabelName = gagvr::CampaignLabelName.FromCustomerCampaignLabel("[CUSTOMER]", "[CAMPAIGN_LABEL]"),
                CampaignAsCampaignName          = gagvr::CampaignName.FromCustomerCampaign("[CUSTOMER]", "[CAMPAIGN]"),
                LabelAsLabelName = gagvr::LabelName.FromCustomerLabel("[CUSTOMER]", "[LABEL]"),
            };

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

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

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