public async stt::Task GetChangeStatusRequestObjectAsync() { moq::Mock <ChangeStatusService.ChangeStatusServiceClient> mockGrpcClient = new moq::Mock <ChangeStatusService.ChangeStatusServiceClient>(moq::MockBehavior.Strict); GetChangeStatusRequest request = new GetChangeStatusRequest { ResourceNameAsChangeStatusName = gagvr::ChangeStatusName.FromCustomerChangeStatus("[CUSTOMER]", "[CHANGE_STATUS]"), }; gagvr::ChangeStatus expectedResponse = new gagvr::ChangeStatus { ResourceNameAsChangeStatusName = gagvr::ChangeStatusName.FromCustomerChangeStatus("[CUSTOMER]", "[CHANGE_STATUS]"), LastChangeDateTime = "last_change_date_time05524d04", ResourceType = gagve::ChangeStatusResourceTypeEnum.Types.ChangeStatusResourceType.Feed, CampaignAsCampaignName = gagvr::CampaignName.FromCustomerCampaign("[CUSTOMER]", "[CAMPAIGN]"), AdGroupAsAdGroupName = gagvr::AdGroupName.FromCustomerAdGroup("[CUSTOMER]", "[AD_GROUP]"), ResourceStatus = gagve::ChangeStatusOperationEnum.Types.ChangeStatusOperation.Unspecified, AdGroupAdAsAdGroupAdName = gagvr::AdGroupAdName.FromCustomerAdGroupAd("[CUSTOMER]", "[AD_GROUP_AD]"), AdGroupCriterionAsAdGroupCriterionName = gagvr::AdGroupCriterionName.FromCustomerAdGroupCriterion("[CUSTOMER]", "[AD_GROUP_CRITERION]"), CampaignCriterionAsCampaignCriterionName = gagvr::CampaignCriterionName.FromCustomerCampaignCriterion("[CUSTOMER]", "[CAMPAIGN_CRITERION]"), FeedAsFeedName = gagvr::FeedName.FromCustomerFeed("[CUSTOMER]", "[FEED]"), FeedItemAsFeedItemName = gagvr::FeedItemName.FromCustomerFeedItem("[CUSTOMER]", "[FEED_ITEM]"), AdGroupFeedAsAdGroupFeedName = gagvr::AdGroupFeedName.FromCustomerAdGroupFeed("[CUSTOMER]", "[AD_GROUP_FEED]"), CampaignFeedAsCampaignFeedName = gagvr::CampaignFeedName.FromCustomerCampaignFeed("[CUSTOMER]", "[CAMPAIGN_FEED]"), AdGroupBidModifierAsAdGroupBidModifierName = gagvr::AdGroupBidModifierName.FromCustomerAdGroupBidModifier("[CUSTOMER]", "[AD_GROUP_BID_MODIFIER]"), }; mockGrpcClient.Setup(x => x.GetChangeStatusAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <gagvr::ChangeStatus>(stt::Task.FromResult(expectedResponse), null, null, null, null)); ChangeStatusServiceClient client = new ChangeStatusServiceClientImpl(mockGrpcClient.Object, null); gagvr::ChangeStatus responseCallSettings = await client.GetChangeStatusAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); Assert.AreEqual(expectedResponse, responseCallSettings); gagvr::ChangeStatus responseCancellationToken = await client.GetChangeStatusAsync(request, st::CancellationToken.None); Assert.AreEqual(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public async Task GetChangeStatusAsync2() { Mock <ChangeStatusService.ChangeStatusServiceClient> mockGrpcClient = new Mock <ChangeStatusService.ChangeStatusServiceClient>(MockBehavior.Strict); GetChangeStatusRequest request = new GetChangeStatusRequest { ResourceName = new ChangeStatusName("[CUSTOMER]", "[CHANGE_STATUS]").ToString(), }; ChangeStatus expectedResponse = new ChangeStatus { ResourceName = "resourceName2625949903", }; mockGrpcClient.Setup(x => x.GetChangeStatusAsync(request, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <ChangeStatus>(Task.FromResult(expectedResponse), null, null, null, null)); ChangeStatusServiceClient client = new ChangeStatusServiceClientImpl(mockGrpcClient.Object, null); ChangeStatus response = await client.GetChangeStatusAsync(request); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }