I am a db4o newbie and am having a problem successfully completing the basic operation of persisting an object and having the retrieval of that object return data matching the original object. The test shown in the code below fails on the assert statement highlighted in bold. The value in retrievedObject.CheckinFlightSegment.DepartureDateTime.TimeZone is not populated in the retrieved object even though it was populated in the original object that was stored.
I have attached a zip with the following files:
- OriginalObject.jpg - Screen capture of debug watch window showing originalObject immediately before storing in the database.
- RetrievedObject.jpg - Screen capture of debug watch window showing retrievedObject immediately after retrieving from the database.
- TestDatabase.db - Db4o database after completion of the test.
- UnitTestSessionCapture.jpg - Screen capture showing the unit test result at the point of failure.
- Db4oTest.cs - The test source code (essentially same as shown below).
I would appreciate any assistance in determining why this process isn't working correctly. If there is any additional information that is needed, please let me know.
[Test]
public void Db4oTest
{
string dbFileName = "TestDatabase.db";
IObjectContainer db = null;
//ensure that we are starting with a clean database
if(File.Exists(dbFileName)) File.Delete(dbFileName);
//configure and open the database
Db4oFactory.Configure().ObjectClass(typeof(Checkin)).CascadeOnUpdate(true);
Db4oFactory.Configure().ObjectClass(typeof(Checkin)).CascadeOnActivate(true);
db = Db4oFactory.OpenFile(dbFileName);
//create the object to be persisted
Checkin originalObject = createCheckin();
//persist the object and close the database
db.Store(originalObject);
db.Commit();
db.Close();
//re-open the database and retrieve the object
db = Db4oFactory.OpenFile(dbFileName);
IObjectSet queryResult = db.QueryByExample(typeof(Checkin));
Checkin retrievedObject = (Checkin) queryResult[0];
//validate the retrieved object
Assert.AreEqual(originalObject.CheckinId, retrievedObject.CheckinId);
Assert.AreEqual(originalObject.CheckinFlightSegment.DepartureDateTime.TimeZone,
retrievedObject.CheckinFlightSegment.DepartureDateTime.TimeZone);
db.Close();
}