Esempio n. 1
0
        public async void Create()
        {
            Mock <ILogger <LessonXStudentRepository> > loggerMoc = LessonXStudentRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = LessonXStudentRepositoryMoc.GetContext();
            var repository = new LessonXStudentRepository(loggerMoc.Object, context);

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

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

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

            LessonXStudent entity = new LessonXStudent();

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

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

            record.Should().NotBeNull();
        }
Esempio n. 3
0
        public async void Delete()
        {
            Mock <ILogger <LessonXStudentRepository> > loggerMoc = LessonXStudentRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = LessonXStudentRepositoryMoc.GetContext();
            var            repository    = new LessonXStudentRepository(loggerMoc.Object, context);
            LessonXStudent entity        = new LessonXStudent();

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

            await repository.Delete(entity.Id);

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

            modifiedRecord.Should().BeNull();
        }
Esempio n. 4
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <LessonXStudentRepository> > loggerMoc = LessonXStudentRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = LessonXStudentRepositoryMoc.GetContext();
            var            repository    = new LessonXStudentRepository(loggerMoc.Object, context);
            LessonXStudent entity        = new LessonXStudent();

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

            await repository.Update(new LessonXStudent());

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

            modifiedRecord.Should().NotBeNull();
        }