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