public virtual void Write(IWriteContext context, object obj) { _writeCalls++; FieldsToTypeHandlerMigrationTestCase.Item item = (FieldsToTypeHandlerMigrationTestCase.Item )obj; context.WriteInt(item._id + 42); }
public virtual void Activate(IReferenceActivationContext context) { _readCalls++; FieldsToTypeHandlerMigrationTestCase.Item item = (FieldsToTypeHandlerMigrationTestCase.Item )((UnmarshallingContext)context).PersistentObject(); item._id = context.ReadInt() - 42; }
public virtual void TestTypeHandler() { _typeHandler = new FieldsToTypeHandlerMigrationTestCase.ItemTypeHandler(); Store(new FieldsToTypeHandlerMigrationTestCase.Item(42)); AssertTypeHandlerCalls(1, 0); FieldsToTypeHandlerMigrationTestCase.Item item = RetrieveOnlyItemInstance(); Assert.AreEqual(42, item._id); AssertTypeHandlerCalls(0, 1); UpdateItem(); AssertTypeHandlerCalls(1, 1); }
private void Store(FieldsToTypeHandlerMigrationTestCase.Item item) { IObjectContainer db = OpenContainer(); try { db.Store(item); } finally { db.Close(); } }
private FieldsToTypeHandlerMigrationTestCase.Item RetrieveOnlyItemInstance() { IObjectContainer db = OpenContainer(); try { IObjectSet objectSet = db.Query(typeof(FieldsToTypeHandlerMigrationTestCase.Item) ); Assert.AreEqual(1, objectSet.Count); FieldsToTypeHandlerMigrationTestCase.Item item = (FieldsToTypeHandlerMigrationTestCase.Item )objectSet.Next(); return(item); } finally { db.Close(); } }
private void AssertItemStoredField(object expectedValue) { IObjectContainer db = OpenContainer(); try { IObjectSet objectSet = db.Query(typeof(FieldsToTypeHandlerMigrationTestCase.Item) ); Assert.AreEqual(1, objectSet.Count); FieldsToTypeHandlerMigrationTestCase.Item item = (FieldsToTypeHandlerMigrationTestCase.Item )objectSet.Next(); IStoredField storedField = db.Ext().StoredClass(typeof(FieldsToTypeHandlerMigrationTestCase.Item )).StoredField("_id", null); object actualValue = storedField.Get(item); Assert.AreEqual(expectedValue, actualValue); } finally { db.Close(); } }