Unit testing WebApi 2 ApiController with ExecuteAsync overriden -


i have apicontroller executeasync method overriden (i using ravendb , here create 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 write automated tests using xunit or microsoft test framework , @ moment i'm stuck calling controllers action via executeasync.

should construct controllercontext in particular way have done or missing something?

simply creating controller object , calling actions throws nullreferenceexception session object, not created executeasync has not been called.


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -