예제 #1
0
        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();
        }
예제 #2
0
        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();
        }
예제 #3
0
        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);
        }