Inheritance: TestResult
Exemple #1
0
        public void Run(TestConfig config)
        {
            int count = config.Count;
            var res   = new TestBitResult();

            config.Result = res;

            DateTime  start = DateTime.Now;
            IDatabase db    = config.GetDatabase();

            Catalogue root = (Catalogue)db.Root;

            Tests.Assert(root == null);
            root             = new Catalogue();
            root.optionIndex = db.CreateBitIndex <Car>();
            root.modelIndex  = db.CreateFieldIndex <string, Car>("model", IndexType.Unique);
            db.Root          = root;

            long rnd = 1999;
            int  i, n;

            Options selectedOptions = Options.TURBO | Options.DISEL | Options.FWD | Options.ABS | Options.EBD | Options.ESP | Options.AIR_COND | Options.HATCHBACK | Options.CLASS_C;
            Options unselectedOptions = Options.AUTOMATIC;

            for (i = 0, n = 0; i < count; i++)
            {
                Options options = (Options)rnd;
                Car     car     = new Car();
                car.hps           = i;
                car.maxSpeed      = car.hps * 10;
                car.timeTo100     = 12;
                car.vendor        = "Toyota";
                car.specification = "unknown";
                car.model         = Convert.ToString(rnd);
                car.options       = options;
                root.modelIndex.Put(car);
                root.optionIndex[car] = (int)options;
                if ((options & selectedOptions) == selectedOptions && (options & unselectedOptions) == 0)
                {
                    n += 1;
                }
                rnd = (3141592621L * rnd + 2718281829L) % 1000000007L;
            }
            res.InsertTime = DateTime.Now - start;

            start = DateTime.Now;
            i     = 0;
            foreach (Car car in root.optionIndex.Select((int)selectedOptions, (int)unselectedOptions))
            {
                Tests.Assert((car.options & selectedOptions) == selectedOptions);
                Tests.Assert((car.options & unselectedOptions) == 0);
                i += 1;
            }
            Tests.Assert(i == n);
            res.SearchTime = DateTime.Now - start;

            start = DateTime.Now;
            i     = 0;
            foreach (Car car in root.modelIndex)
            {
                root.optionIndex.Remove(car);
                car.Deallocate();
                i += 1;
            }
            Tests.Assert(i == count);
            root.optionIndex.Clear();
            res.RemoveTime = DateTime.Now - start;
            db.Close();
        }
Exemple #2
0
        public void Run(TestConfig config)
        {
            int count = config.Count;
            var res = new TestBitResult();
            config.Result = res;

            DateTime start = DateTime.Now;
            IDatabase db = config.GetDatabase();

            Catalogue root = (Catalogue)db.Root;
            Tests.Assert(root == null);
            root = new Catalogue();
            root.optionIndex = db.CreateBitIndex<Car>();
            root.modelIndex = db.CreateFieldIndex<string, Car>("model", IndexType.Unique);
            db.Root = root;

            long rnd = 1999;
            int i, n;

            Options selectedOptions = Options.TURBO | Options.DISEL | Options.FWD | Options.ABS | Options.EBD | Options.ESP | Options.AIR_COND | Options.HATCHBACK | Options.CLASS_C;
            Options unselectedOptions = Options.AUTOMATIC;

            for (i = 0, n = 0; i < count; i++)
            {
                Options options = (Options)rnd;
                Car car = new Car();
                car.hps = i;
                car.maxSpeed = car.hps * 10;
                car.timeTo100 = 12;
                car.vendor = "Toyota";
                car.specification = "unknown";
                car.model = Convert.ToString(rnd);
                car.options = options;
                root.modelIndex.Put(car);
                root.optionIndex[car] = (int)options;
                if ((options & selectedOptions) == selectedOptions && (options & unselectedOptions) == 0)
                {
                    n += 1;
                }
                rnd = (3141592621L * rnd + 2718281829L) % 1000000007L;
            }
            res.InsertTime = DateTime.Now - start;

            start = DateTime.Now;
            i = 0;
            foreach (Car car in root.optionIndex.Select((int)selectedOptions, (int)unselectedOptions))
            {
                Tests.Assert((car.options & selectedOptions) == selectedOptions);
                Tests.Assert((car.options & unselectedOptions) == 0);
                i += 1;
            }
            Tests.Assert(i == n);
            res.SearchTime = DateTime.Now - start;

            start = DateTime.Now;
            i = 0;
            foreach (Car car in root.modelIndex)
            {
                root.optionIndex.Remove(car);
                car.Deallocate();
                i += 1;
            }
            Tests.Assert(i == count);
            root.optionIndex.Clear();
            res.RemoveTime = DateTime.Now - start;
            db.Close();
        }