J
Jehu Galeahsa
Hello:
I am trying to write a piece of code that can implement an interface's
methods simply by returning a specified value. I am trying to see how
Mock libraries are written.
For instance, I have a piece of code that looks like this:
MockFactory.CreateMock<ISomething>().Setup(something =>
something.Foo()).Returns("abc");
What I want to be able to do is somehow implement ISomething.Foo so
that it returns "abc". However, I am having a hard time figuring out
the Emit code for taking an arbitrary object and incorporating it.
I've never wanted to do something like this before, so I need some
pointers. Also, I am wondering if there is a fast way in MSIL to
request the default value of a type (null or 0) in case no return
value is specified.
Any help would be appreciated.
Thanks,
Travis Parks
I am trying to write a piece of code that can implement an interface's
methods simply by returning a specified value. I am trying to see how
Mock libraries are written.
For instance, I have a piece of code that looks like this:
MockFactory.CreateMock<ISomething>().Setup(something =>
something.Foo()).Returns("abc");
What I want to be able to do is somehow implement ISomething.Foo so
that it returns "abc". However, I am having a hard time figuring out
the Emit code for taking an arbitrary object and incorporating it.
I've never wanted to do something like this before, so I need some
pointers. Also, I am wondering if there is a fast way in MSIL to
request the default value of a type (null or 0) in case no return
value is specified.
Any help would be appreciated.
Thanks,
Travis Parks