I am trying to determine if a method exists and then test if that method has been called. The only interface that is available to the test project in the below example code is I1.
My test code looks like this
This throws this error: "Could not resolve the target method; make sure that you have provided arguments correctly.". I have put this code into the function to make sure that Mock.Create creates the appropriate proxy.
MethodInfo is never null so that tells me that a valid proxy has been created.
My question is: Am I going about this the wrong way? How can I tell if a method that the test only knows by name and not by interface has actually been called?
Thank you for your help.
public
interface
I1 { }
public
interface
I2 : I1
{
void
Test();
}
[TestMethod()]
public
void
MyClassConstructorTest()
{
this
.Test<I2>();
}
public
void
Test<T>() where T : I1
{
T t = Mock.Create<T>();
bool
called =
false
;
Mock.NonPublic.Arrange(t,
"Test"
).DoInstead(() => called =
true
);
}
This throws this error: "Could not resolve the target method; make sure that you have provided arguments correctly.". I have put this code into the function to make sure that Mock.Create creates the appropriate proxy.
MethodInfo method = t.GetType().GetMethod(
"Test"
);
My question is: Am I going about this the wrong way? How can I tell if a method that the test only knows by name and not by interface has actually been called?
Thank you for your help.