I am adding a new content model in Contentful, and I’m using Contentful’s .NET SDK to retrieve its entries. In the past I’ve experienced problems migrating from Newtonsoft.Json to System.Text.Json, including problems triggered by enabling nullable reference types, which caused many unexpected problems with model validation and properties that were implicitly optional.
I want to be able to avoid those in the future, and for that I wanted to write unit tests that verify that calls to Contentful’s GetEntry
and GetEntries
don’t start to blow up unexpectedly at the deserialization stage just because a package was updated. However, this sort of usecase doesn’t seem to be supported by Contentful’s .NET SDK.
So, is there any way to write unit tests that mock the response from Contentful’s API and verify that the deserialization step in Contentful’s .NET SDK still works?