public async void Update_Entity_Is_Not_Tracked() { Mock <ILogger <TestAllFieldTypeRepository> > loggerMoc = TestAllFieldTypeRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = TestAllFieldTypeRepositoryMoc.GetContext(); var repository = new TestAllFieldTypeRepository(loggerMoc.Object, context); TestAllFieldType entity = new TestAllFieldType(); context.Set <TestAllFieldType>().Add(entity); await context.SaveChangesAsync(); await repository.Update(new TestAllFieldType()); var modifiedRecord = context.Set <TestAllFieldType>().FirstOrDefaultAsync(); modifiedRecord.Should().NotBeNull(); }
public async void Update_Entity_Is_Not_Tracked() { Mock <ILogger <TestAllFieldTypeRepository> > loggerMoc = TestAllFieldTypeRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = TestAllFieldTypeRepositoryMoc.GetContext(); var repository = new TestAllFieldTypeRepository(loggerMoc.Object, context); TestAllFieldType entity = new TestAllFieldType(); entity.SetProperties(default(int), 2, BitConverter.GetBytes(2), true, "B", DateTime.Parse("1/1/1988 12:00:00 AM"), DateTime.Parse("1/1/1988 12:00:00 AM"), DateTime.Parse("1/1/1988 12:00:00 AM"), DateTimeOffset.Parse("1/1/1988 12:00:00 AM"), 2m, 2, BitConverter.GetBytes(2), 2m, "B", "B", 2m, "B", 2m, DateTime.Parse("1/1/1988 12:00:00 AM"), 2, 2m, "B", TimeSpan.Parse("02:00:00"), BitConverter.GetBytes(2), 2, Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b"), BitConverter.GetBytes(2), "B", "B"); context.Set <TestAllFieldType>().Add(entity); await context.SaveChangesAsync(); context.Entry(entity).State = EntityState.Detached; await repository.Update(entity); var records = await context.Set <TestAllFieldType>().ToListAsync(); records.Count.Should().Be(2); }