public async void Update_Entity_Is_Not_Tracked() { Mock <ILogger <TimestampCheckRepository> > loggerMoc = TimestampCheckRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = TimestampCheckRepositoryMoc.GetContext(); var repository = new TimestampCheckRepository(loggerMoc.Object, context); TimestampCheck entity = new TimestampCheck(); context.Set <TimestampCheck>().Add(entity); await context.SaveChangesAsync(); await repository.Update(new TimestampCheck()); var modifiedRecord = context.Set <TimestampCheck>().FirstOrDefaultAsync(); modifiedRecord.Should().NotBeNull(); }
public async void Update_Entity_Is_Not_Tracked() { Mock <ILogger <TimestampCheckRepository> > loggerMoc = TimestampCheckRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = TimestampCheckRepositoryMoc.GetContext(); var repository = new TimestampCheckRepository(loggerMoc.Object, context); TimestampCheck entity = new TimestampCheck(); entity.SetProperties(default(int), "B", BitConverter.GetBytes(2)); context.Set <TimestampCheck>().Add(entity); await context.SaveChangesAsync(); context.Entry(entity).State = EntityState.Detached; await repository.Update(entity); var records = await context.Set <TimestampCheck>().ToListAsync(); records.Count.Should().Be(2); }