To enable easier testing of serializers (along with other benefits), interfaces should be introduced where BsonReader and BsonWriter are currently being used.
Old
—
In order to unit test a custom bson serializers, a mock of BsonReader and BsonWriter need to be provided.
If the custom serializer depends on the CurrentBsonType or State properties, it can not be tested easily, as these properties are not virtual, and have protected setters.
There is an ugly workaround to create your own abstract inheritors of the above classes, where one can provide a public method to set these properties, and then for the test to mock that inheritors.
A better approach would be to make these properties virtual, providing for a better user code testability.