keyed Delete unit tests

This commit is contained in:
Sean Garrett
2023-06-16 11:51:40 +01:00
parent 54e756c695
commit c6545b9448
19 changed files with 565 additions and 138 deletions
@@ -1,24 +1,24 @@
using MongoDB.Driver;
using MongoDbGenericRepository.Models;
using System;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Threading.Tasks;
using MongoDB.Driver;
using MongoDbGenericRepository.Models;
namespace MongoDbGenericRepository
{
/// <summary>
/// The IBaseMongoRepository interface exposes the CRUD functionality of the BaseMongoRepository.
/// The IBaseMongoRepository interface exposes the CRUD functionality of the BaseMongoRepository.
/// </summary>
public interface IBaseMongoRepository :
IReadOnlyMongoRepository,
IBaseMongoRepository_Create,
IBaseMongoRepository_Update,
IBaseMongoRepository_Delete,
public interface IBaseMongoRepository :
IReadOnlyMongoRepository,
IBaseMongoRepository_Create,
IBaseMongoRepository_Update,
IBaseMongoRepository_Delete,
IBaseMongoRepository_Index
{
/// <summary>
/// Asynchronously returns a paginated list of the documents matching the filter condition.
/// Asynchronously returns a paginated list of the documents matching the filter condition.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="filter"></param>
@@ -29,7 +29,7 @@ namespace MongoDbGenericRepository
where TDocument : IDocument;
/// <summary>
/// Asynchronously returns a paginated list of the documents matching the filter condition.
/// Asynchronously returns a paginated list of the documents matching the filter condition.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
@@ -42,7 +42,7 @@ namespace MongoDbGenericRepository
where TKey : IEquatable<TKey>;
/// <summary>
/// GetAndUpdateOne with filter
/// GetAndUpdateOne with filter
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="filter"></param>
@@ -53,7 +53,7 @@ namespace MongoDbGenericRepository
where TDocument : IDocument;
/// <summary>
/// GetAndUpdateOne with filter
/// GetAndUpdateOne with filter
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
@@ -62,8 +62,7 @@ namespace MongoDbGenericRepository
/// <param name="options"></param>
/// <returns></returns>
Task<TDocument> GetAndUpdateOne<TDocument, TKey>(FilterDefinition<TDocument> filter, UpdateDefinition<TDocument> update, FindOneAndUpdateOptions<TDocument, TDocument> options)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
}
}
}
@@ -41,6 +41,13 @@ namespace MongoDbGenericRepository
return MongoDbEraser.DeleteOne<TDocument, TKey>(document);
}
/// <inheritdoc />
public virtual long DeleteOne<TDocument>(Expression<Func<TDocument, bool>> filter, string partitionKey = null)
where TDocument : IDocument<TKey>
{
return MongoDbEraser.DeleteOne<TDocument, TKey>(filter, partitionKey);
}
/// <inheritdoc />
public virtual async Task<long> DeleteOneAsync<TDocument>(TDocument document)
where TDocument : IDocument<TKey>
@@ -83,13 +90,6 @@ namespace MongoDbGenericRepository
return await MongoDbEraser.DeleteOneAsync<TDocument, TKey>(filter, partitionKey, cancellationToken);
}
/// <inheritdoc />
public virtual long DeleteOne<TDocument>(Expression<Func<TDocument, bool>> filter, string partitionKey = null)
where TDocument : IDocument<TKey>
{
return MongoDbEraser.DeleteOne<TDocument, TKey>(filter, partitionKey);
}
/// <inheritdoc />
public virtual async Task<long> DeleteManyAsync<TDocument>(IEnumerable<TDocument> documents)
where TDocument : IDocument<TKey>
@@ -104,7 +104,6 @@ namespace MongoDbGenericRepository
return await MongoDbEraser.DeleteManyAsync<TDocument, TKey>(documents, cancellationToken);
}
/// <inheritdoc />
public async Task<long> DeleteManyAsync<TDocument>(Expression<Func<TDocument, bool>> filter)
where TDocument : IDocument<TKey>