public void DeleteNotFound() { Mock <ILogger <TableRepository> > loggerMoc = TableRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = TableRepositoryMoc.GetContext(); var repository = new TableRepository(loggerMoc.Object, context); Func <Task> delete = async() => { await repository.Delete(default(int)); }; delete.Should().NotThrow(); }
public async void Delete() { Mock <ILogger <TableRepository> > loggerMoc = TableRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = TableRepositoryMoc.GetContext(); var repository = new TableRepository(loggerMoc.Object, context); Table entity = new Table(); context.Set <Table>().Add(entity); await context.SaveChangesAsync(); await repository.Delete(entity.Id); Table modifiedRecord = await context.Set <Table>().FirstOrDefaultAsync(); modifiedRecord.Should().BeNull(); }
public async void DeleteFound() { Mock <ILogger <TableRepository> > loggerMoc = TableRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = TableRepositoryMoc.GetContext(); var repository = new TableRepository(loggerMoc.Object, context); Table entity = new Table(); entity.SetProperties(default(int), "B"); context.Set <Table>().Add(entity); await context.SaveChangesAsync(); await repository.Delete(entity.Id); var records = await context.Set <Table>().ToListAsync(); records.Count.Should().Be(1); }