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