Beispiel #1
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <TeacherSkillRepository> > loggerMoc = TeacherSkillRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = TeacherSkillRepositoryMoc.GetContext();
            var          repository      = new TeacherSkillRepository(loggerMoc.Object, context);
            TeacherSkill entity          = new TeacherSkill();

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

            await repository.Update(new TeacherSkill());

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

            modifiedRecord.Should().NotBeNull();
        }
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <TeacherSkillRepository> > loggerMoc = TeacherSkillRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = TeacherSkillRepositoryMoc.GetContext();
            var          repository      = new TeacherSkillRepository(loggerMoc.Object, context);
            TeacherSkill entity          = new TeacherSkill();

            entity.SetProperties(default(int), "B");
            context.Set <TeacherSkill>().Add(entity);
            await context.SaveChangesAsync();

            context.Entry(entity).State = EntityState.Detached;

            await repository.Update(entity);

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

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