I am busy design a web service with asp.net web api. And I want to start doing unit tests on each controller.
here is my test class so far:
[TestClass]
public class MyDevicesControllerTest
{
[TestMethod]
public void TestValidUser()
{
MyDeviceController controller = new MyDeviceController();
var result = controller.Get();
}
[TestMethod]
public void TestInvalidUser()
{
MyDeviceController controller = new MyDeviceController();
var result = controller.Get();
}
}
But my web service makes use of token authentication. So I some how need to emulate the authentication process.
So I was thinking my i not maybe make user of a Http Request to test it? Ie instead of testing the controller I just make a http Request and check its answer?
What is the easier / better way to go about testing it?