Esempio n. 1
0
        public async void Get()
        {
            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();

            var record = await repository.Get(entity.Id);

            record.Should().NotBeNull();
        }
Esempio n. 2
0
        public async void Update_Entity_Is_Tracked()
        {
            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();

            var record = await repository.Get(entity.Id);

            await repository.Update(record);

            var modifiedRecord = context.Set <Table>().FirstOrDefaultAsync();

            modifiedRecord.Should().NotBeNull();
        }
Esempio n. 3
0
        public async void Update_Entity_Is_Tracked()
        {
            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();

            var record = await repository.Get(entity.Id);

            await repository.Update(record);

            var records = await context.Set <Table>().ToListAsync();

            records.Count.Should().Be(2);
        }