public void GetCampaignDraft() { moq::Mock <CampaignDraftService.CampaignDraftServiceClient> mockGrpcClient = new moq::Mock <CampaignDraftService.CampaignDraftServiceClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); GetCampaignDraftRequest request = new GetCampaignDraftRequest { ResourceNameAsCampaignDraftName = gagvr::CampaignDraftName.FromCustomerCampaignDraft("[CUSTOMER]", "[CAMPAIGN_DRAFT]"), }; gagvr::CampaignDraft expectedResponse = new gagvr::CampaignDraft { ResourceNameAsCampaignDraftName = gagvr::CampaignDraftName.FromCustomerCampaignDraft("[CUSTOMER]", "[CAMPAIGN_DRAFT]"), DraftId = -3652444185194679204L, BaseCampaignAsCampaignName = gagvr::CampaignName.FromCustomerCampaign("[CUSTOMER]", "[CAMPAIGN]"), CampaignDraftName = gagvr::CampaignDraftName.FromCustomerCampaignDraft("[CUSTOMER]", "[CAMPAIGN_DRAFT]"), DraftCampaignAsCampaignName = gagvr::CampaignName.FromCustomerCampaign("[CUSTOMER]", "[CAMPAIGN]"), Status = gagve::CampaignDraftStatusEnum.Types.CampaignDraftStatus.Removed, HasExperimentRunning = true, LongRunningOperation = "long_running_operation0897bd41", }; mockGrpcClient.Setup(x => x.GetCampaignDraft(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); CampaignDraftServiceClient client = new CampaignDraftServiceClientImpl(mockGrpcClient.Object, null); gagvr::CampaignDraft response = client.GetCampaignDraft(request.ResourceName); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async stt::Task GetCampaignDraftRequestObjectAsync() { moq::Mock <CampaignDraftService.CampaignDraftServiceClient> mockGrpcClient = new moq::Mock <CampaignDraftService.CampaignDraftServiceClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); GetCampaignDraftRequest request = new GetCampaignDraftRequest { ResourceNameAsCampaignDraftName = gagvr::CampaignDraftName.FromCustomerCampaignDraft("[CUSTOMER]", "[CAMPAIGN_DRAFT]"), }; gagvr::CampaignDraft expectedResponse = new gagvr::CampaignDraft { ResourceNameAsCampaignDraftName = gagvr::CampaignDraftName.FromCustomerCampaignDraft("[CUSTOMER]", "[CAMPAIGN_DRAFT]"), DraftId = -3652444185194679204L, BaseCampaignAsCampaignName = gagvr::CampaignName.FromCustomerCampaign("[CUSTOMER]", "[CAMPAIGN]"), CampaignDraftName = gagvr::CampaignDraftName.FromCustomerCampaignDraft("[CUSTOMER]", "[CAMPAIGN_DRAFT]"), DraftCampaignAsCampaignName = gagvr::CampaignName.FromCustomerCampaign("[CUSTOMER]", "[CAMPAIGN]"), Status = gagve::CampaignDraftStatusEnum.Types.CampaignDraftStatus.Removed, HasExperimentRunning = true, LongRunningOperation = "long_running_operation0897bd41", }; mockGrpcClient.Setup(x => x.GetCampaignDraftAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <gagvr::CampaignDraft>(stt::Task.FromResult(expectedResponse), null, null, null, null)); CampaignDraftServiceClient client = new CampaignDraftServiceClientImpl(mockGrpcClient.Object, null); gagvr::CampaignDraft responseCallSettings = await client.GetCampaignDraftAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); Assert.AreEqual(expectedResponse, responseCallSettings); gagvr::CampaignDraft responseCancellationToken = await client.GetCampaignDraftAsync(request, st::CancellationToken.None); Assert.AreEqual(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }