You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Such that when snapshotting an Order its Customer will be converted to a string.
I am currently achieving this by registering a custom converter that projects Order for serialization.
However, I instinctively dislike this approach as it feels brittle, and will be harder to maintain:
classCustomConverter<T>(Func<T?,object?>convert):WriteOnlyJsonConverter<T?>{publicoverridevoidWrite(VerifyJsonWriterwriter,T?value){writer.Serializer.Serialize(writer,convert(value));}}VerifierSettings.AddExtraSettings(settings =>{settings.Converters.Add(newCustomConverter<Order>(
o =>new{ ...}));});
The text was updated successfully, but these errors were encountered:
I am currently achieving this by registering a custom converter that projects Order for serialization.
However, I instinctively dislike this approach as it feels brittle, and will be harder to maintain:
I would prefer to snapshot Order directly, so that if it is refactored in future I can be sure this will lead to changed snapshots, forcing a review of the tests. The projection gets in the way of this. (For example, the projection won't change if a new member is added to Order.)
But I suppose that's just my preference for my particular situation. What do you think of the idea in principle? I think it might be nice simplification to be able to remap a member to a different type for serialization, without needing the ceremony of a custom converter + projection.
sorry i dont see this as adding any value over a custom serializer. you are free to extend Verify and ship that custom behaviour in your own nuget package
I would like to be able to do something like this:
Such that when snapshotting an
Order
itsCustomer
will be converted to astring
.I am currently achieving this by registering a custom converter that projects
Order
for serialization.However, I instinctively dislike this approach as it feels brittle, and will be harder to maintain:
The text was updated successfully, but these errors were encountered: