Details
-
Improvement
-
Resolution: Fixed
-
Major
-
3.2.1
-
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:
- Make the setters public on all XXXErrorContext classes
- 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.
Attachments
Issue Links
- links to