I'm trying to do something along the lines of:
A.CallTo(() => fakeTimer.Start()).Invokes(() =>
fakeTimer.Elapsed += Raise.With<ElapsedEventArgs>(ElapsedEventArgs.Empty).Now);
The fakeTimer
is a fake of ITimer
, a wrapper interface per this answer.
Obviously this doesn't work, since I cannot do an assignment inside an Experssion Tree.
What I am actually tying to achieve is simulating raising timer events when the Start
method was called. This way I can assert that a call to Start
indeed happened.
Any (alternative) ideas?
Edit I'm an idiot and the fault is my own! I accidentally added an extra A.CallTo
, where I shouldn't have. Instead of deleting this question, I'll keep it to award Patrik Hägne his rightful reputation :)
A.CallTo(() => { ... })
. – Silage{...}
) cannot be converted to an Expression Tree... – ConcavoconvexExpression<Action>
(source link). You might have to explicitly cast it then, sinceAction
andExpression<Action>
are technically ambiguous:(Expression<Action>)(() => ... )
. – Silage