It seems it is possible to compare two delegates in C# for equality, but I cannot figure out if one can compare two variables of type Func<>
Func<Task<Foo>> a = () => _service.GetFoo();
Func<Task<Foo>> b = () => _service.GetFoo();
Is it possible to do some comparison of these?
P.S. I need this for unit testing, I do pass a delegate like that to another method and I'd like to test that this is what is being passed (not _service.GetBar()
that is). I have now solved this by calling the delegate and comparing the result, but I'd rather compare it directly if it is possible.
P.P.S. This is not duplicate even though people made it look like that. The other question is about expressions and it's a completely special thing in C# that is not an ordinary delegate.