< Summary

Information
Class: MRA.Services.Models.Documents.DocumentModelService<T1, T2>
Assembly: MRA.Services
File(s): D:\a\MiguelRomerART\MiguelRomerART\MRA.Services\Models\Documents\DocumentModelService.cs
Line coverage
100%
Covered lines: 18
Uncovered lines: 0
Coverable lines: 18
Total lines: 50
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
ExistsAsync()100%11100%
GetAllAsync()100%11100%
FindAsync()100%11100%
SetAsync()100%11100%
DeleteAsync()100%11100%

File(s)

D:\a\MiguelRomerART\MiguelRomerART\MRA.Services\Models\Documents\DocumentModelService.cs

#LineLine coverage
 1using MRA.DTO.Mapper.Interfaces;
 2using MRA.DTO.Models.Interfaces;
 3using MRA.Infrastructure.Database.Documents.Interfaces;
 4using MRA.Infrastructure.Database.Providers.Interfaces;
 5
 6namespace MRA.Services.Models.Documents;
 7
 8public abstract class DocumentModelService<Model, Document> : IDocumentModelService<Model>
 9    where Model : IModel
 10    where Document : IDocument
 11{
 12    private readonly string _collectionName;
 13    private readonly IDocumentsDatabase _db;
 14    protected IDocumentMapper<Model, Document> Converter;
 15
 3616    protected DocumentModelService(string collectionName, IDocumentMapper<Model, Document> converter, IDocumentsDatabase
 17    {
 3618        _collectionName = collectionName;
 3619        Converter = converter;
 3620        _db = db;
 3621    }
 22
 23    public async Task<bool> ExistsAsync(string id)
 24    {
 1525        return await _db.DocumentExistsAsync(_collectionName, id);
 1426    }
 27
 28    public async Task<IEnumerable<Model>> GetAllAsync()
 29    {
 830        var documentList = (await _db.GetAllDocumentsAsync<Document>(_collectionName));
 731        return documentList.Select(Converter.ConvertToModel);
 732    }
 33
 34    public async Task<Model> FindAsync(string id)
 35    {
 1136        var document = await _db.GetDocumentAsync<Document>(_collectionName, id);
 1037        return Converter.ConvertToModel(document);
 938    }
 39
 40    public async Task<bool> SetAsync(string id, Model model)
 41    {
 1042        var document = Converter.ConvertToDocument(model);
 943        return await _db.SetDocumentAsync(_collectionName, id, document);
 844    }
 45
 46    public async Task<bool> DeleteAsync(string id)
 47    {
 248        return await _db.DeleteDocumentAsync(_collectionName, id);
 149    }
 50}