Currently, all controllers are tested using unit tests. This is useful, as we can ensure that the controller action methods when instantiating an instance of the controller class do indeed work. However, we have no way of actually knowing, in a programmatic way, whether HTTP calls through to the routes described on those controllers actually work correctly.
As such, add a set of integration tests for both of the GET endpoints on the BookController controller class.
High-Level Proposed Solution
Create a test csproj for integration tests
Ensure that we are using the WebApplicationFactory of Startup from the BookApi csproj
Write integration tests which test the following scenarios:
api/Book/GET returns a 200 OK response when the provided GUID is valid
api/Book/GET returns a 400 Bad Request response when the provided GUID is invalid
api/Book/GET returns a 404 Not Found response when no GUID is provided
api/Book/GetPaged returns a 200 OK response when the provided POCO is valid
api/Book/GetPaged returns a 400 Bad Request response when the provided POCO is invalid
api/Book/GetPaged returns a 404 No Found response when the provided POCO is not present
This is not an exhaustive list
Also include tests on the returned data (if applicable)
Description
Currently, all controllers are tested using unit tests. This is useful, as we can ensure that the controller action methods when instantiating an instance of the controller class do indeed work. However, we have no way of actually knowing, in a programmatic way, whether HTTP calls through to the routes described on those controllers actually work correctly.
As such, add a set of integration tests for both of the GET endpoints on the
BookController
controller class.High-Level Proposed Solution
WebApplicationFactory
ofStartup
from the BookApi csprojapi/Book/GET
returns a 200 OK response when the provided GUID is validapi/Book/GET
returns a 400 Bad Request response when the provided GUID is invalidapi/Book/GET
returns a 404 Not Found response when no GUID is providedapi/Book/GetPaged
returns a 200 OK response when the provided POCO is validapi/Book/GetPaged
returns a 400 Bad Request response when the provided POCO is invalidapi/Book/GetPaged
returns a 404 No Found response when the provided POCO is not presentConsiderations
Requirements
bookApi.IntegrationTests
)bookApi.Tests
tobookApi.UnitTests
, or similar