< Summary

Information
Class: event_list.modules.eventlist.storage.EventListStorage
Assembly: event-list
File(s): /Users/tiagoamaral/Workspace/desafio/event-list-api/Src/Modules/Eventlist/Storage/EventListStorage.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 25
Coverable lines: 25
Total lines: 49
Line coverage: 0%
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%210%
CreateAsync()100%210%
DeleteAsync()0%620%
GetAllAsync()100%210%
GetByIdAsync()100%210%

File(s)

/Users/tiagoamaral/Workspace/desafio/event-list-api/Src/Modules/Eventlist/Storage/EventListStorage.cs

#LineLine coverage
 1/*
 2* EventListStorageTests.cs
 3* event-list
 4*
 5* Created by Tiago Amaral on 06/09/2025.
 6* Copyright ©2024 Tiago Amaral. All rights reserved.
 7*/
 8
 9namespace event_list.modules.eventlist.storage;
 10public class EventListStorage : IEventListStorage
 11{
 12    private readonly EventListDbContext _context;
 13
 014    public EventListStorage(EventListDbContext context)
 015    {
 016        _context = context;
 017    }
 18    public async Task CreateAsync(EventFormDto entity)
 019    {
 020        await _context.Events.AddAsync(entity);
 021        await _context.SaveChangesAsync();
 022    }
 23
 24    public async Task DeleteAsync(Guid id)
 025    {
 26
 027        var eventItem = await _context.Events.FindAsync(id);
 028        if (eventItem != null) {
 029            _context.Events.Remove(eventItem);
 030            await _context.SaveChangesAsync();
 031        }
 032    }
 33
 34    // public IEnumerable<EventFormDto> GetAllAsync() => _context.Events.ToList();
 35
 36    public IEnumerable<EventListDto> GetAllAsync()
 037    {
 38
 039        return _context.Events.Select(e => new EventListDto
 040            {
 041                Id = e.Id,
 042                Title = e.Title,
 043                Date = e.Date
 044            })
 045            .ToList();
 046    }
 47
 048    public async Task<EventFormDto?> GetByIdAsync(Guid id) => await _context.Events.FindAsync(id);
 49}