是否可以调用 func 事件?

问题描述

出于测试目的,我想在 azures ProcessMessageAsync 事件上调用处理程序。

我试过使用 moq Raise

processor.Raise(p => p.ProcessMessageAsync += null,processEvent.Object);

但是不能使用这个,因为 azure 有这个空检查

        public event Func<ProcessMessageEventArgs,Task> ProcessMessageAsync
        {
            add
            {
                Argument.AssertNotNull(value,nameof(ProcessMessageAsync));

                if (_processMessageAsync != default)
                {
#pragma warning disable CA1065 // Do not raise exceptions in unexpected locations
                    throw new NotSupportedException(Resources.HandlerHasAlreadyBeenAssigned);
#pragma warning restore CA1065 // Do not raise exceptions in unexpected locations
                }
                EnsureNotRunningAndInvoke(() => _processMessageAsync = value);
            }

是否可以调用添加到 ProcessMessageAsync 的处理程序?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)