Uploaded image for project: 'Couchbase .NET client library'
  1. Couchbase .NET client library
  2. NCBC-2925

KeyValueErrorContext and other error context properties should have public setters

    XMLWordPrintable

Details

    • Improvement
    • Resolution: Fixed
    • Major
    • 3.2.0
    • 3.2.1
    • library
    • 1

    Description

      When writing unit tests against service code, it's likely that SDK consumers will mock the SDK interfaces. When they do, one scenario they need to implement is mocking cases where the SDK throws an exception. This is done by artificially creating and throwing CouchbaseException or classes inherited from CouchbaseException.

      When constructing a CouchbaseException in a unit test, it currently isn't possible to effectively emulate specific IErrorContext implementations such as KeyValueErrorContext. This is because KeyValueErrorContext's properties currently have internal setters rather than public.

      I'd propose one of two solutions:

      1. Make the setters public on all XXXErrorContext classes
      2. Or, add IXXXErrorContext interfaces for each XXXErrorContext class so that a more complete interface may be mocked, and make XXXErrorContext internal as a whole

      I'd lean towards option #1 because it's simpler for the consumer, especially since these are basically just POCOs without any internal logic. However, option #2 is more future-proof.

      https://forums.couchbase.com/t/mocking-a-getasync/31111

      Attachments

        Issue Links

          For Gerrit Dashboard: NCBC-2925
          # Subject Branch Project Status CR V

          Activity

            People

              btburnett3 Brant Burnett
              btburnett3 Brant Burnett
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes

                  PagerDuty