< Summary

Information
Class: MRA.Services.Models.Collections.CollectionService
Assembly: MRA.Services
File(s): D:\a\MiguelRomerART\MiguelRomerART\MRA.Services\Models\Collections\CollectionService.cs
Line coverage
10%
Covered lines: 2
Uncovered lines: 17
Coverable lines: 19
Total lines: 60
Line coverage: 10.5%
Branch coverage
0%
Covered branches: 0
Total branches: 2
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
GetAllCollectionsAsync()100%210%
FindCollectionAsync()100%210%
ExistsCollection()100%210%
SaveCollectionAsync()100%210%
DeleteCollection()100%210%
CheckIfExistsCollectionAsync()0%620%

File(s)

D:\a\MiguelRomerART\MiguelRomerART\MRA.Services\Models\Collections\CollectionService.cs

#LineLine coverage
 1using MRA.Infrastructure.Settings;
 2using MRA.DTO.Models;
 3using MRA.Services.Models.Documents;
 4using MRA.DTO.Exceptions;
 5using MRA.Infrastructure.Database.Providers.Interfaces;
 6using MRA.DTO.Mapper.Interfaces;
 7using MRA.Infrastructure.Database.Documents.Interfaces;
 8using MRA.DTO.Exceptions.Collections;
 9using System.Linq.Expressions;
 10using MRA.DTO.Mapper;
 11
 12namespace MRA.Services.Models.Collections;
 13
 14public class CollectionService : DocumentModelService<CollectionModel, ICollectionDocument>, ICollectionService
 15{
 16    public CollectionService(
 17        AppSettings appConfig,
 18        IDocumentsDatabase db)
 119        : base(collectionName: appConfig.Database.Collections.Collections, new CollectionMapper(), db)
 20    {
 121    }
 22
 23    public async Task<IEnumerable<CollectionModel>> GetAllCollectionsAsync(bool onlyIfVisible)
 24    {
 025        var collections = await GetAllAsync();
 026        return collections;
 027    }
 28
 29    public async Task<CollectionModel> FindCollectionAsync(string id)
 30    {
 031        await CheckIfExistsCollectionAsync(id);
 32
 033        return await FindAsync(id);
 034    }
 35
 36    public async Task<bool> ExistsCollection(string id)
 37    {
 038        return await ExistsAsync(id);
 039    }
 40
 41    public async Task<bool> SaveCollectionAsync(string id, CollectionModel collection)
 42    {
 043        return await SetAsync(id, collection);
 044    }
 45
 46    public async Task<bool> DeleteCollection(string id)
 47    {
 048        await CheckIfExistsCollectionAsync(id);
 49
 050        return await DeleteAsync(id);
 051    }
 52
 53    private async Task CheckIfExistsCollectionAsync(string id)
 54    {
 055        var exists = await ExistsAsync(id);
 056        if (!exists)
 057            throw new CollectionNotFoundException(id);
 058    }
 59
 60}