Skip to content

Test full pipeline with dependency resolver #292

@MisterSokol

Description

@MisterSokol

While trying to run test for full pipeline for controller that should run with dependencies I got an error that the controller should have parameters public constructor.

Error message:

MyTested.WebApi.Exceptions.HttpResponseMessageAssertionException: 'When testing ServerHttpMessageHandler expected HTTP response message result status code to be 200 (OK), but instead received 500 (InternalServerError).

The code:

MyWebApi
.IsRegisteredWith(WebApiConfig.Register)
.WithDependencyResolver(() =>
{
SimpleInjectorWebApiInitializer.TestInitialize();
return new SimpleInjectorWebApiDependencyResolver(SimpleInjectorWebApiInitializer.Container);
})
.AndStartsServer()
.WithHttpRequestMessage(req => req
.WithMethod(HttpMethod.Get)
.WithRequestUri("api/values/5")
)
.ShouldReturnHttpResponseMessage()
.WithStatusCode(HttpStatusCode.OK)
.WithResponseModel("value");

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions