예제 #1
0
 private void Store <T>(NullableHolder <T> holder) where T : struct
 {
     using (IObjectContainer db = Db4oFactory.OpenFile(TempFilePath()))
     {
         _logger.LogMessage("Storing ", holder.ToString());
         db.Store(holder);
     }
 }
예제 #2
0
 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.");
     }
 }
예제 #3
0
        private bool Equals(NullableHolder <T> other)
        {
            if (!Compare(_nullables, other._nullables))
            {
                return(false);
            }
            if (!Compare(_listOfNullables, other._listOfNullables))
            {
                return(false);
            }

            return(true);
        }
예제 #4
0
        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");
        }
예제 #5
0
        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());
        }
예제 #6
0
        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));
        }
예제 #7
0
        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);
            }
        }
예제 #8
0
        private void TestDescending <T>(NullableHolder <T> expected, T candidate) where T : struct
        {
            NullableHolder <T> actual = DescendingQuery(candidate);

            Compare(expected, actual);
        }