Exemplo n.º 1
0
        public async void Create()
        {
            Mock <ILogger <LessonRepository> > loggerMoc = LessonRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = LessonRepositoryMoc.GetContext();
            var repository = new LessonRepository(loggerMoc.Object, context);

            var entity = new Lesson();
            await repository.Create(entity);

            var record = await context.Set <Lesson>().FirstOrDefaultAsync();

            record.Should().NotBeNull();
        }
Exemplo n.º 2
0
        public async void Get()
        {
            Mock <ILogger <LessonRepository> > loggerMoc = LessonRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = LessonRepositoryMoc.GetContext();
            var repository = new LessonRepository(loggerMoc.Object, context);

            Lesson entity = new Lesson();

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

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

            record.Should().NotBeNull();
        }
Exemplo n.º 3
0
        public async void Delete()
        {
            Mock <ILogger <LessonRepository> > loggerMoc = LessonRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = LessonRepositoryMoc.GetContext();
            var    repository            = new LessonRepository(loggerMoc.Object, context);
            Lesson entity = new Lesson();

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

            await repository.Delete(entity.Id);

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

            modifiedRecord.Should().BeNull();
        }
Exemplo n.º 4
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <LessonRepository> > loggerMoc = LessonRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = LessonRepositoryMoc.GetContext();
            var    repository            = new LessonRepository(loggerMoc.Object, context);
            Lesson entity = new Lesson();

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

            await repository.Update(new Lesson());

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

            modifiedRecord.Should().NotBeNull();
        }