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

Make the ReplaceX methods from class MongoCollectionBase<TDocument> virtual

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 2.11.0
    • Affects Version/s: 2.10.1
    • Component/s: API
    • None

       

      The class:

       

      public abstract class MongoCollectionBase<TDocument> : IMongoCollection<TDocument>

       

       

       

      does not have the following methods as virtual:

       

      public ReplaceOneResult ReplaceOne(FilterDefinition<TDocument> filter, TDocument replacement, ReplaceOptions options = null, CancellationToken cancellationToken = default);
      public ReplaceOneResult ReplaceOne(IClientSessionHandle session, FilterDefinition<TDocument> filter, TDocument replacement, ReplaceOptions options = null, CancellationToken cancellationToken = default);
      public Task<ReplaceOneResult> ReplaceOneAsync(FilterDefinition<TDocument> filter, TDocument replacement, ReplaceOptions options = null, CancellationToken cancellationToken = default);
      public Task<ReplaceOneResult> ReplaceOneAsync(IClientSessionHandle session, FilterDefinition<TDocument> filter, TDocument replacement, ReplaceOptions options = null, CancellationToken cancellationToken = default);
      

       

       

      Therefore they cannot be mocked with Moq in the unit tests.

      Is it possible to have them changed?

       

       

            Assignee:
            mikalai.mazurenka@mongodb.com Mikalai Mazurenka (Inactive)
            Reporter:
            lucian.naie@gmail.com Lucian Naie
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: