コード例 #1
0
        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);
        }
コード例 #2
0
        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));
        }
コード例 #3
0
        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));
        }