Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-1029

Introduce interfaces for IBsonReader/IBsonWriter

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.0
    • Affects Version/s: 1.9.2
    • Component/s: BSON
    • Labels:
    • Fully Compatible

      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.

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            sunnybg Svetoslav Milenov
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: