示例#1
0
        public async void Delete()
        {
            Mock <ILogger <RateRepository> > loggerMoc = RateRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext             context   = RateRepositoryMoc.GetContext();
            var  repository = new RateRepository(loggerMoc.Object, context);
            Rate entity     = new Rate();

            context.Set <Rate>().Add(entity);
            await context.SaveChangesAsync();

            await repository.Delete(entity.Id);

            Rate modifiedRecord = await context.Set <Rate>().FirstOrDefaultAsync();

            modifiedRecord.Should().BeNull();
        }
示例#2
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <RateRepository> > loggerMoc = RateRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext             context   = RateRepositoryMoc.GetContext();
            var  repository = new RateRepository(loggerMoc.Object, context);
            Rate entity     = new Rate();

            context.Set <Rate>().Add(entity);
            await context.SaveChangesAsync();

            await repository.Update(new Rate());

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

            modifiedRecord.Should().NotBeNull();
        }