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

Introduce interfaces for IBsonReader/IBsonWriter

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • 2.0
    • 1.9.2
    • BSON
    • Fully Compatible

    Description

      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.

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: