Is there a way to Mock the AttemptContext

I am using the AttemptContext to implement Transactions in Couchbase.
I am using Couchbase.Transactions version 3.6.2.
I am trying to Mock the AttemptContext, but it does not have a default constructor , it does not implement an interface and the constructor that does exist is marked as internal
Is there any plans to make the AttemptContext mockable ?

Currently no plans to make it mockable.

Thanks, but too bad does not implement an interface. :slightly_frowning_face:

Looks like AttemptContext is in flux, just wondering if there are plans to re work the AttemptContext object ?

[InterfaceStability(Level.Volatile)]
public class AttemptContext

As far as I know, there are no plans to rework it.
I’m wondering what kind of testing needs mocking AttemptContext? Why not just use a real transaction?

I am using the AttemptContext to implement Transactions in Couchbase.

Transactions are already implemented in Couchbase (?).

I have a class that accepts an AcceptContext In the constructor, and methods in this class wraps methods on the AcceptContext:
GetAsync
GetOptionalAsync
RemoveAsync
ReplaceAsync
InsertAsync

Wanted to mock the responses to these methods, where my method wrappers will throw appropriate exceptions, if something goes wrong with an individual call, or the above will return appropriate mocked responses, in happy path tests

I am not testing Couchbase Transactions., but my code that manages the AcceptContext Calls, therefore the need to mock AcceptContext, and the responses to the above calls

Seems odd, that Scope, Bucket, Collection , Cluster all have interfaces:
IScope, IBucket, ICouchBaseCollection., ICluster.
But AttemptContext does not.

If I am running these tests in a build pipeline, was avoiding running a Couchbase Container instance in the pipeline.

Hi @MMMda -

What your asking for makes sense. We can look into adding an IAttemptContext interface in the future.

Thanks,
Jeff

Thank-you for your response, I am hoping that the TransactionGetResult object will have also implement an interface.
Thanks Again :smile: