public void TrackUnseenEntities() { var collection = new EntityCollection <TestEntity>(); var processor = new EntityTrackingProcessor <TestEntity>(collection); processor.ProcessEntity(new TestEntity { Id = "123", Description = "Database" }, null); var collectionEntity = collection.GetEntry(new TestEntity { Id = "123" }).Entity; Assert.AreEqual("Database", collectionEntity.Description); }
public void TrackUnseenEntities() { var connection = TestConfiguration.GetConnection(); var context = new MongoDbContext(connection); var processor = new EntityTrackingProcessor <TestEntity>(context); processor.ProcessEntity(new TestEntity { Id = "123", Description = "Database" }, null); var collectionEntity = context.ChangeTracker.GetEntry(new TestEntity { Id = "123" }).Entity as TestEntity; Assert.AreEqual("Database", collectionEntity.Description); }
public void DontRefreshEntityIfMarkedForUpdate() { var collection = new EntityCollection <TestEntity>(); var processor = new EntityTrackingProcessor <TestEntity>(collection); collection.Update(new TestEntity { Id = "123", Description = "Updated" }, EntityEntryState.Updated); processor.ProcessEntity(new TestEntity { Id = "123", Description = "Database" }, null); var collectionEntity = collection.GetEntry(new TestEntity { Id = "123" }).Entity; Assert.AreEqual("Updated", collectionEntity.Description); }
public void RefreshEntityIfMarkedAsNoChanges() { var collection = new EntityCollection <TestEntity>(); var processor = new EntityTrackingProcessor <TestEntity>(collection); collection.Update(new TestEntity { Id = "123", Description = "1" }, EntityEntryState.NoChanges); processor.ProcessEntity(new TestEntity { Id = "123", Description = "2" }, null); var collectionEntity = collection.GetEntry(new TestEntity { Id = "123" }).Entity; Assert.AreEqual("2", collectionEntity.Description); }
public void DontRefreshEntityIfMarkedForUpdate() { var connection = TestConfiguration.GetConnection(); var context = new MongoDbContext(connection); var processor = new EntityTrackingProcessor <TestEntity>(context); context.ChangeTracker.SetEntityState(new TestEntity { Id = "123", Description = "Updated" }, EntityEntryState.Updated); processor.ProcessEntity(new TestEntity { Id = "123", Description = "Database" }, null); var collectionEntity = context.ChangeTracker.GetEntry(new TestEntity { Id = "123" }).Entity as TestEntity; Assert.AreEqual("Updated", collectionEntity.Description); }