Open krilbe opened 7 years ago
Here's the dummy method that works:
public static object Test(string[] a, Type t)
{
if (t.Name.StartsWith("I"))
return a;
else
return a.Length;
}
Here's the unit test method I'm trying with:
[TestMethod]
public void HittarKörningsklassen()
{
Smock.Run(context =>
{
string[] args = new string[] { };
Type paramklass = typeof(TestkörningParams);
context.Setup(() => Körningsparameterhämtare.HämtaParametrar(args, paramklass)).Returns(6);
context.Setup(() => Körningsparameterhämtare.Test(args, paramklass)).Returns(6);
}
If I have the first Setup
line there, I get a NullReferenceException
on the Smock.Run
line. If I comment it out, everything runs just fine.
I have a static class with a single static method, but whenever I try to Setup a mock call to it, I get a NullReferenceException. If I write another method with the same signature, but dummy code, and Setup that one instead, it works. So there must be something within my method that Smocks can't handle correctly.
Here's the complete method:
The method
LoggaOchKastaUndantag
just logs the message (log4net) and then throws an exception with the same message:Sorry about the Swedish identifiers... What might be "wrong" with the method? It does seem to work as intended outside of Smocks.