コード例 #1
0
 public void GetConversionActionRequestObject()
 {
     moq::Mock<ConversionActionService.ConversionActionServiceClient> mockGrpcClient = new moq::Mock<ConversionActionService.ConversionActionServiceClient>(moq::MockBehavior.Strict);
     GetConversionActionRequest request = new GetConversionActionRequest
     {
         ResourceNameAsConversionActionName = gagvr::ConversionActionName.FromCustomerConversionAction("[CUSTOMER]", "[CONVERSION_ACTION]"),
     };
     gagvr::ConversionAction expectedResponse = new gagvr::ConversionAction
     {
         ResourceNameAsConversionActionName = gagvr::ConversionActionName.FromCustomerConversionAction("[CUSTOMER]", "[CONVERSION_ACTION]"),
         Id = -6774108720365892680L,
         ConversionActionName = gagvr::ConversionActionName.FromCustomerConversionAction("[CUSTOMER]", "[CONVERSION_ACTION]"),
         Status = gagve::ConversionActionStatusEnum.Types.ConversionActionStatus.Hidden,
         Type = gagve::ConversionActionTypeEnum.Types.ConversionActionType.GooglePlayInAppPurchase,
         Category = gagve::ConversionActionCategoryEnum.Types.ConversionActionCategory.AddToCart,
         OwnerCustomer = "owner_customer43abc24a",
         IncludeInConversionsMetric = false,
         ClickThroughLookbackWindowDays = -4831593457096707011L,
         ViewThroughLookbackWindowDays = -8283075401830951626L,
         ValueSettings = new gagvr::ConversionAction.Types.ValueSettings(),
         CountingType = gagve::ConversionActionCountingTypeEnum.Types.ConversionActionCountingType.Unspecified,
         AttributionModelSettings = new gagvr::ConversionAction.Types.AttributionModelSettings(),
         TagSnippets =
         {
             new gagvc::TagSnippet(),
         },
         PhoneCallDurationSeconds = -8070508326407639729L,
         AppId = "app_idfead82f3",
     };
     mockGrpcClient.Setup(x => x.GetConversionAction(request, moq::It.IsAny<grpccore::CallOptions>())).Returns(expectedResponse);
     ConversionActionServiceClient client = new ConversionActionServiceClientImpl(mockGrpcClient.Object, null);
     gagvr::ConversionAction response = client.GetConversionAction(request);
     Assert.AreEqual(expectedResponse, response);
     mockGrpcClient.VerifyAll();
 }
        public async stt::Task GetConversionActionRequestObjectAsync()
        {
            moq::Mock <ConversionActionService.ConversionActionServiceClient> mockGrpcClient = new moq::Mock <ConversionActionService.ConversionActionServiceClient>(moq::MockBehavior.Strict);
            GetConversionActionRequest request = new GetConversionActionRequest
            {
                ResourceNameAsConversionActionName = gagvr::ConversionActionName.FromCustomerConversionAction("[CUSTOMER_ID]", "[CONVERSION_ACTION_ID]"),
            };
            gagvr::ConversionAction expectedResponse = new gagvr::ConversionAction
            {
                ResourceNameAsConversionActionName = gagvr::ConversionActionName.FromCustomerConversionAction("[CUSTOMER_ID]", "[CONVERSION_ACTION_ID]"),
                Status                   = gagve::ConversionActionStatusEnum.Types.ConversionActionStatus.Hidden,
                Type                     = gagve::ConversionActionTypeEnum.Types.ConversionActionType.Salesforce,
                Category                 = gagve::ConversionActionCategoryEnum.Types.ConversionActionCategory.AddToCart,
                ValueSettings            = new gagvr::ConversionAction.Types.ValueSettings(),
                CountingType             = gagve::ConversionActionCountingTypeEnum.Types.ConversionActionCountingType.Unspecified,
                AttributionModelSettings = new gagvr::ConversionAction.Types.AttributionModelSettings(),
                TagSnippets              =
                {
                    new gagvc::TagSnippet(),
                },
                MobileAppVendor  = gagve::MobileAppVendorEnum.Types.MobileAppVendor.GoogleAppStore,
                FirebaseSettings = new gagvr::ConversionAction.Types.FirebaseSettings(),
                ThirdPartyAppAnalyticsSettings = new gagvr::ConversionAction.Types.ThirdPartyAppAnalyticsSettings(),
                Id = -6774108720365892680L,
                ConversionActionName           = gagvr::ConversionActionName.FromCustomerConversionAction("[CUSTOMER_ID]", "[CONVERSION_ACTION_ID]"),
                OwnerCustomerAsCustomerName    = gagvr::CustomerName.FromCustomer("[CUSTOMER_ID]"),
                IncludeInConversionsMetric     = false,
                ClickThroughLookbackWindowDays = -4831593457096707011L,
                ViewThroughLookbackWindowDays  = -8283075401830951626L,
                PhoneCallDurationSeconds       = -8070508326407639729L,
                AppId          = "app_idfead82f3",
                Origin         = gagve::ConversionOriginEnum.Types.ConversionOrigin.App,
                PrimaryForGoal = false,
            };

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

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

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