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