Reputation: 8098
I'm trying to write tests for a Nancy project. I've stripped my test back to bare basics but am still getting a seemingly bizarre result.
The module:
public class HomeModule : BaseModule
{
public HomeModule(IUserMapper mapper)
{
Get["/"] = "Hello, world!";
}
}
The test:
[Test]
public void Home_Index_should_return_response_OK()
{
var result = GetBrowser().Get("/", with => with.HttpRequest());
Assert.AreEqual(HttpStatusCode.OK, result.StatusCode);
}
The assert fails with this message:
Expected: OK
But was: OK
WTF? Both results are of type HttpStatusCode
and value "OK". If I add .GetValue()
or .ToString()
to them both, the assert passes but it feels vary hack-y and something something 'code smell'.
At first I thought it might be a quirk with nUnit and testing enums but when I try something like this:
var value = ActionTargets.Suite;
Assert.AreEqual(ActionTargets.Suite,value);
it passes fine.
Upvotes: 2
Views: 276
Reputation: 8098
Argggh.... I've been ReShafted..
I just found this at the top of the file which I'm certain I didn't put there myself.
using HttpStatusCode = System.Net.HttpStatusCode;
Lesson to be learned here: don't blindly rely on tooling to do your thinking for you.
Upvotes: 4