I'm very new to testing and just starting out and want to know how could I make my AuthorizationService
testable.
Reason is that I can't use Ninject to inject HttpContext.Current.Request into my AuthorizationService(IHttpContext context)
since it has no interface.
How should I proceed?
Code
public class AuthorizationService : IAuthorizationService
{
private readonly string _token;
public AuthorizationService()
{
var headerValues = HttpContext.Current.Request.Headers.GetValues("Token");
var paramValues = HttpContext.Current.Request.QueryString.GetValues("Token");
var headerToken = string.Empty;
var paramToken = string.Empty;
// ... some logic ...
this._token = headerToken;
}
/// <summary>
/// Just some random function that will return the token
/// </summary>
/// <returns></returns>
public string GetToken()
{
return this._token;
}
}