public async void Update_Entity_Is_Not_Tracked() { Mock <ILogger <BucketRepository> > loggerMoc = BucketRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = BucketRepositoryMoc.GetContext(); var repository = new BucketRepository(loggerMoc.Object, context); Bucket entity = new Bucket(); context.Set <Bucket>().Add(entity); await context.SaveChangesAsync(); await repository.Update(new Bucket()); var modifiedRecord = context.Set <Bucket>().FirstOrDefaultAsync(); modifiedRecord.Should().NotBeNull(); }
public async void Update_Entity_Is_Not_Tracked() { Mock <ILogger <BucketRepository> > loggerMoc = BucketRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = BucketRepositoryMoc.GetContext(); var repository = new BucketRepository(loggerMoc.Object, context); Bucket entity = new Bucket(); entity.SetProperties(default(int), Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b"), "B"); context.Set <Bucket>().Add(entity); await context.SaveChangesAsync(); context.Entry(entity).State = EntityState.Detached; await repository.Update(entity); var records = await context.Set <Bucket>().ToListAsync(); records.Count.Should().Be(2); }