public async void Update_Entity_Is_Not_Tracked() { Mock <ILogger <PostHistoryRepository> > loggerMoc = PostHistoryRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = PostHistoryRepositoryMoc.GetContext(); var repository = new PostHistoryRepository(loggerMoc.Object, context); PostHistory entity = new PostHistory(); context.Set <PostHistory>().Add(entity); await context.SaveChangesAsync(); await repository.Update(new PostHistory()); var modifiedRecord = context.Set <PostHistory>().FirstOrDefaultAsync(); modifiedRecord.Should().NotBeNull(); }
public async void Update_Entity_Is_Not_Tracked() { Mock <ILogger <PostHistoryRepository> > loggerMoc = PostHistoryRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = PostHistoryRepositoryMoc.GetContext(); var repository = new PostHistoryRepository(loggerMoc.Object, context); PostHistory entity = new PostHistory(); entity.SetProperties(default(int), "B", DateTime.Parse("1/1/1988 12:00:00 AM"), 1, 1, "B", "B", "B", 1); context.Set <PostHistory>().Add(entity); await context.SaveChangesAsync(); context.Entry(entity).State = EntityState.Detached; await repository.Update(entity); var records = await context.Set <PostHistory>().ToListAsync(); records.Count.Should().Be(2); }