public async Task Handle_SetsReportToCleared_WhenTheReportIdIsFound(int extraReports) { //arrange var report = new Report { Prompt = new Prompt() }; DbContext.Reports.Add(report); for (var i = 0; i < extraReports; i++) { DbContext.Reports.Add(new Report { Prompt = new Prompt() }); } await DbContext.SaveChangesAsync(); var command = new ClearReportCommand(report.Id); //act await _handler.Handle(command); //assert Assert.True(DbContext.Reports.Find(report.Id).Cleared); }
public async Task Handle_ThrowsClearReportNotFoundException_WhenTheDatabaseIsEmpty(int id) { //arrange var command = new ClearReportCommand(id); //act + assert await Assert.ThrowsAsync <ClearReportNotFoundException>(async() => await _handler.Handle(command)); }
public async Task Handle_ThrowsClearReportNotFoundException_WhenTheReportIdIsNotFound(int id) { //arrange DbContext.Reports.Add(new Report { Prompt = new Prompt() }); await DbContext.SaveChangesAsync(); var command = new ClearReportCommand(id); //act + assert await Assert.ThrowsAsync <ClearReportNotFoundException>(async() => await _handler.Handle(command)); }