I have ApiController with ExecuteAsync
method overriden like this (I am using RavenDB and here I create its session):
public override async Task<HttpResponseMessage> ExecuteAsync(
HttpControllerContext controllerContext,
CancellationToken cancellationToken)
{
using (Session = Store.OpenAsyncSession())
{
var result = await base.ExecuteAsync(controllerContext, cancellationToken);
await Session.SaveChangesAsync();
return result;
}
}
I want to write automated Tests for it using xUnit or Microsoft Test Framework and at the moment I'm stuck with calling controllers action via ExecuteAsync.
Should I construct ControllerContext in any particular way to have that done or am I missing something?
Simply creating controller object and calling actions throws NullReferenceException for Session object, which is obviously not created as the ExecuteAsync has not been called.
Aucun commentaire:
Enregistrer un commentaire