示例#1
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <TagRepository> > loggerMoc = TagRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext            context   = TagRepositoryMoc.GetContext();
            var repository = new TagRepository(loggerMoc.Object, context);
            Tag entity     = new Tag();

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

            await repository.Update(new Tag());

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

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

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

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

            await repository.Update(entity);

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

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