< Summary

Information
Class: ArturRios.Data.MongoDb.MongoContext
Assembly: ArturRios.Data.MongoDb
File(s): D:\Repositories\dotnet-data\src\ArturRios.Data.MongoDb\MongoContext.cs
Line coverage
100%
Covered lines: 3
Uncovered lines: 0
Coverable lines: 3
Total lines: 19
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage
100%
Covered methods: 3
Fully covered methods: 3
Total methods: 3
Method coverage: 100%
Full method coverage: 100%

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
get_Session()100%11100%
GetCollection()100%11100%

File(s)

D:\Repositories\dotnet-data\src\ArturRios.Data.MongoDb\MongoContext.cs

#LineLine coverage
 1using MongoDB.Driver;
 2
 3namespace ArturRios.Data.MongoDb;
 4
 5/// <summary>
 6///     Wraps an <see cref="IMongoDatabase" /> and carries the ambient client session used to enlist
 7///     repository operations in the Mongo unit of work transaction.
 8/// </summary>
 9/// <param name="database">The MongoDB database.</param>
 1810public class MongoContext(IMongoDatabase database)
 11{
 12    /// <summary>The ambient transaction session, or <see langword="null" /> when none is active.</summary>
 5213    public IClientSessionHandle? Session { get; set; }
 14
 15    /// <summary>Returns the collection for <typeparamref name="T" /> using the naming convention.</summary>
 16    /// <typeparam name="T">The document type.</typeparam>
 17    public IMongoCollection<T> GetCollection<T>() where T : Document =>
 4718        database.GetCollection<T>(CollectionName.For<T>());
 19}