Exemplo n.º 1
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <LinkTypeRepository> > loggerMoc = LinkTypeRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = LinkTypeRepositoryMoc.GetContext();
            var      repository          = new LinkTypeRepository(loggerMoc.Object, context);
            LinkType entity = new LinkType();

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

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

            await repository.Update(entity);

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

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