private void Store <T>(NullableHolder <T> holder) where T : struct { using (IObjectContainer db = Db4oFactory.OpenFile(TempFilePath())) { _logger.LogMessage("Storing ", holder.ToString()); db.Store(holder); } }
private void Compare <T>(NullableHolder <T> stored, NullableHolder <T> retrieved) where T : struct { if (stored != retrieved) { _logger.LogMessage("Stored and retrieved objects differ.\r\n\r\nStored : \r\n {0}\r\nRetrieved: {1}", stored.ToString(), retrieved.ToString()); } else { _logger.LogMessage("Objects matches."); } }
private bool Equals(NullableHolder <T> other) { if (!Compare(_nullables, other._nullables)) { return(false); } if (!Compare(_listOfNullables, other._listOfNullables)) { return(false); } return(true); }
private void Test <T>(NullableHolder <T> holder) where T : struct { _logger.LogMessage("------------- Testing with type: {0} ------------- ", typeof(T).Name); Store(holder); var results = Query <T>(); if (results.Count != 0) { Compare(holder, results[0]); } _logger.LogMessage("------------- Finished ------------- \r\n"); }
private void CreateDatabaseInOlderVersion() { _logger.LogMessage("Creating database ({0}) at version {1}.)", DATABASE_PATH, Db4oVersion.Name); NullableHolder <bool> obj = new NullableHolder <bool>(new bool?[] { true, false, null, false, true }); using (IObjectContainer container = Db4oFactory.OpenFile(DATABASE_PATH)) { container.Store(obj); } _logger.LogMessage("Object {0} added to database.", obj.ToString()); }
public override bool Equals(object obj) { if (obj == null) { return(false); } if (obj.GetType() != GetType()) { return(false); } NullableHolder <T> other = (NullableHolder <T>)obj; return(Equals(other)); }
protected override void Run() { try { NullableHolder <int> intHolder = new NullableHolder <int>(new int?[] { Int32.MinValue, 0, Int32.MaxValue, null, 0xDB40 }); Test(intHolder); Test(new NullableHolder <CustomValueType>(new CustomValueType?[] { new CustomValueType("Foo", 1), null, new CustomValueType("Bar", 3) })); TestDescending(intHolder, 0xDB40); File.Delete(TempFilePath()); } catch (Exception ex) { _logger.LogException(ex); } }
private void TestDescending <T>(NullableHolder <T> expected, T candidate) where T : struct { NullableHolder <T> actual = DescendingQuery(candidate); Compare(expected, actual); }