[CSHARP-2927] Make the ReplaceX methods from class MongoCollectionBase<TDocument> virtual Created: 05/Feb/20  Updated: 28/Oct/23  Resolved: 09/Jul/20

Status: Closed
Project: C# Driver
Component/s: API
Affects Version/s: 2.10.1
Fix Version/s: 2.11.0

Type: Improvement Priority: Major - P3
Reporter: Lucian Naie Assignee: Mikalai Mazurenka (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

 

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?

 

 



 Comments   
Comment by Githook User [ 09/Jul/20 ]

Author:

{'name': 'Mikalai Mazurenka', 'email': 'mikalai.mazurenka@mongodb.com', 'username': 'MikalaiMazurenka'}

Message: CSHARP-2927: Make the ReplaceX methods from class MongoCollectionBase<TDocument> virtual
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/7fc793b742dc2bd21253f9498b70e729d241b5a2

Comment by Lucian Naie [ 05/Feb/20 ]

Given that the ReplaceX methods that are using the UpdateOptions param were marked Obsolete, we're forced to use the ones with ReplaceOptions param. Sure, but then the unit testing needs some help from you.  Thanks!

Generated at Wed Feb 07 21:43:53 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.