public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <FamilyRepository> > loggerMoc = FamilyRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = FamilyRepositoryMoc.GetContext();
            var    repository            = new FamilyRepository(loggerMoc.Object, context);
            Family entity = new Family();

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

            await repository.Update(new Family());

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

            modifiedRecord.Should().NotBeNull();
        }
Exemple #2
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <FamilyRepository> > loggerMoc = FamilyRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = FamilyRepositoryMoc.GetContext();
            var    repository            = new FamilyRepository(loggerMoc.Object, context);
            Family entity = new Family();

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

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

            await repository.Update(entity);

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

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