I have a call as such:
_session.Setup(session => session.SaveOrUpdate(It.IsAny<Foo>()))
I want to retrieve a copy of whatever instance of Foo
is passed into SaveOrUpdate
when the test is run for validation. How can I get a copy of that exact Foo
into my test?
I tried to use .Callback
, but maybe that is not the way to do this? Or maybe I'm doing it wrong... not sure, but I could use some assistance trying to figure out if this is possible and how to do this please.
Foo foo;
_session.Setup(session => session.SaveOrUpdate(It.IsAny<Foo>()))
.Callback<Foo>(fooInstanceBeingSaved => foo = fooInstanceBeingSaved as Foo);
In this scenario, foo
is always returned null
, even though the real foo
in the service layer is populated.
EDIT: This is not a duplicate of said duplicate because this question differs in that SaveOrUpdate returns void. In the reportedly duplicate articles, those methods return something other than void. As such, I need to get the variable out of a method where "Returns" is not a valid option - which is the solution in the other articles.