Closed
Description
A primary goal of this task is to make it easy to write end to end tests without thinking about json:api.
- Decouple deserialization (depends on Posting JSONAPI data not binding #237)
- Fluent testing API (RFC: Fluent Testing API #294)
- Possible issue with data type precision during deserialization (needs investigation)
- Documentation around best practices for testing
- Improve exception messages during serialization
- Need to include comment (or come up with better solution) about how to use
IScopedServiceProvider
. See ScopedServiceProvider should throw helpful exception when outside HttpContext #362 for interim solution. - Should provide a simple way to create the
ResourceGraph
andJsonApiContext
outside of a web request.
Current workaround:
public class MockJsonApiContextFactory
{
public static Mock<IJsonApiContext> GetWithSingleResource<TResource, TId>()
where TResource : class, IIdentifiable<TId>
{
var resourceGraph = new ResourceGraphBuilder()
.AddResource<TResource, TId>()
.Build();
var requestEntity = resourceGraph.GetContextEntity(typeof(TResource));
var jsonApiContextMock = new Mock<IJsonApiContext>();
jsonApiContextMock.Setup(c => c.ResourceGraph).Returns(resourceGraph);
jsonApiContextMock.Setup(c => c.RequestEntity).Returns(requestEntity);
return jsonApiContextMock;
}
}
- Consider adding "enhanced exception messages" if the environment is
test
(or something along those lines)