public void GetRemarketingAction() { moq::Mock <RemarketingActionService.RemarketingActionServiceClient> mockGrpcClient = new moq::Mock <RemarketingActionService.RemarketingActionServiceClient>(moq::MockBehavior.Strict); GetRemarketingActionRequest request = new GetRemarketingActionRequest { ResourceNameAsRemarketingActionName = gagvr::RemarketingActionName.FromCustomerRemarketingAction("[CUSTOMER]", "[REMARKETING_ACTION]"), }; gagvr::RemarketingAction expectedResponse = new gagvr::RemarketingAction { ResourceNameAsRemarketingActionName = gagvr::RemarketingActionName.FromCustomerRemarketingAction("[CUSTOMER]", "[REMARKETING_ACTION]"), Id = -6774108720365892680L, RemarketingActionName = gagvr::RemarketingActionName.FromCustomerRemarketingAction("[CUSTOMER]", "[REMARKETING_ACTION]"), TagSnippets = { new gagvc::TagSnippet(), }, }; mockGrpcClient.Setup(x => x.GetRemarketingAction(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); RemarketingActionServiceClient client = new RemarketingActionServiceClientImpl(mockGrpcClient.Object, null); gagvr::RemarketingAction response = client.GetRemarketingAction(request.ResourceName); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async stt::Task GetRemarketingActionRequestObjectAsync() { moq::Mock <RemarketingActionService.RemarketingActionServiceClient> mockGrpcClient = new moq::Mock <RemarketingActionService.RemarketingActionServiceClient>(moq::MockBehavior.Strict); GetRemarketingActionRequest request = new GetRemarketingActionRequest { ResourceNameAsRemarketingActionName = gagvr::RemarketingActionName.FromCustomerRemarketingAction("[CUSTOMER]", "[REMARKETING_ACTION]"), }; gagvr::RemarketingAction expectedResponse = new gagvr::RemarketingAction { ResourceNameAsRemarketingActionName = gagvr::RemarketingActionName.FromCustomerRemarketingAction("[CUSTOMER]", "[REMARKETING_ACTION]"), Id = -6774108720365892680L, RemarketingActionName = gagvr::RemarketingActionName.FromCustomerRemarketingAction("[CUSTOMER]", "[REMARKETING_ACTION]"), TagSnippets = { new gagvc::TagSnippet(), }, }; mockGrpcClient.Setup(x => x.GetRemarketingActionAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <gagvr::RemarketingAction>(stt::Task.FromResult(expectedResponse), null, null, null, null)); RemarketingActionServiceClient client = new RemarketingActionServiceClientImpl(mockGrpcClient.Object, null); gagvr::RemarketingAction responseCallSettings = await client.GetRemarketingActionAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); Assert.AreEqual(expectedResponse, responseCallSettings); gagvr::RemarketingAction responseCancellationToken = await client.GetRemarketingActionAsync(request, st::CancellationToken.None); Assert.AreEqual(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }