I have a class containing a method which returns a Result object which contains a property of type Func.
class Result {
public Func<Result> NextAction { get; set; }
}
How do I write a unit test assertion regarding the content of this Func? The following obviously does not work, because the compiler generates two different methods for the lambda:
// Arrange
ListController controller = new ListController(domain);
// Act
Result actual = controller.DefaultAction();
// Assert
Func<Result> expected = () => new ProductsController(domain).ListAction();
Assert.That(actual.NextAction, Is.EqualTo(expected));
I'm guessing that I could do this by using expression trees instead, but... is there a way to avoid doing so? I'm using NUnit 2.5.
EDIT: There are no other identifying fields in the Result object. It is intended to be a way of invoking the next object/method based on a decision made in the current object/method.