public async Task GetAllReportAsync_WhenGot_ListOfReportExpected()
        {
            // Arrange
            var init = InitReport();
            await _context.Reports.AddAsync(init);

            await _context.SaveChangesAsync();

            // Act
            var result = await _reportService.GetAllReportAsync();

            var report = result.FirstOrDefault(x => x.Id == init.Id);

            // Assert
            Assert.True(result.Count == 5);
            Assert.NotNull(report);
            Assert.Equal(init.SummaryPrice, report.SummaryPrice);
            Assert.Equal(init.OrderDate, report.OrderDate);
        }
        /// <inheritdoc />
        public async Task <Report> CreateReportAsync(Report newReport)
        {
            if (newReport == null)
            {
                throw new ArgumentNullException(nameof(newReport));
            }

            await _context.Reports.AddAsync(newReport);

            await _context.SaveChangesAsync();

            var addedReport = await _context.Reports.FirstOrDefaultAsync(x => x.Id == newReport.Id);

            if (addedReport == null)
            {
                throw new ItemNotFoundException($"Error occured while adding report from {newReport.OrderDate}");
            }
            return(addedReport);
        }
Esempio n. 3
0
 public async Task CompleteAsync()
 {
     await _context.SaveChangesAsync();
 }