/// <exception cref="System.Exception"></exception>
        public virtual void SetUp()
        {
            IEmbeddedObjectContainer db = OpenDatabase();

            db.Store(new ConcurrentRenameTestCase.QueryItem());
            db.Store(new ConcurrentRenameTestCase.RenameItem());
            db.Close();
        }
Пример #2
0
        public void Save(object entity)
        {
            if (_db == null)
            {
                BeginTransaction();
            }

            _db.Store(entity);
        }
Пример #3
0
        private static void MakeAndStoreTwoItemsInTwoContainers(IEmbeddedObjectContainer objectContainer,
                                                                int seriesNumber)
        {
            var evenIndex = 2 * seriesNumber;

            var oddIndex = 1 + evenIndex;


            var fred = new Container {
                Name = String.Format("Fred_{0}", evenIndex)
            };

            var itemOne = new Item {
                Name = String.Format("Odd_{0}", oddIndex)
            };

            var itemTwo = new Item {
                Name = String.Format("Even_{0}", evenIndex)
            };

            itemOne.Container = fred;

            itemTwo.Container = fred;


            {
                objectContainer.Store(itemOne);

                objectContainer.Commit();

                var ethel = new Container {
                    Name = String.Format("Ethel_{0}", evenIndex)
                };

                var oldContainer = itemTwo.Container;

                itemTwo.Container = ethel;

                if (oldContainer != fred)
                {
                    throw new Exception("No!");
                }

                if (oldContainer.Items.Count() != 1)
                {
                    throw new Exception("No");
                }


                objectContainer.Store(oldContainer);
                objectContainer.Store(itemTwo);
            }
        }
Пример #4
0
        /// <exception cref="System.Exception"></exception>
        public virtual void SetUp()
        {
            IEmbeddedObjectContainer db = Db4oEmbedded.OpenFile(Config(), DbPath);

            db.Store(new KnownClassesIndexTestCase.WithIndex(42));
            db.Close();
        }
        protected virtual void AssertReplicates(object holder)
        {
            IEmbeddedObjectContainer sourceDb = OpenContainer("source");

            sourceDb.Store(holder);
            sourceDb.Commit();
            IEmbeddedObjectContainer targetDb = OpenContainer("target");

            try
            {
                Db4oEmbeddedReplicationProvider providerA = new Db4oEmbeddedReplicationProvider(sourceDb
                                                                                                );
                Db4oEmbeddedReplicationProvider providerB = new Db4oEmbeddedReplicationProvider(targetDb
                                                                                                );
                IReplicationSession replication = Replication.Begin(providerA, providerB);
                IObjectSet          changed     = replication.ProviderA().ObjectsChangedSinceLastReplication();
                while (changed.HasNext())
                {
                    object o = changed.Next();
                    if (holder.GetType() == o.GetType())
                    {
                        replication.Replicate(o);
                        break;
                    }
                }
                replication.Commit();
            }
            finally
            {
                sourceDb.Close();
                targetDb.Close();
            }
        }
        private void CreateData()
        {
            IEmbeddedObjectContainer database = Db4oEmbedded.OpenFile(TempFile());

            database.Store(new QueryingReadOnlyWithNewClassTestCase.A("Item1"));
            database.Commit();
            database.Close();
        }
Пример #7
0
        private void CreateData()
        {
            IEmbeddedObjectContainer database = Db4oEmbedded.OpenFile(TempFile());

            database.Store(new RenamingClassAfterQueryingTestCase.A("Item1"));
            database.Commit();
            database.Close();
        }
Пример #8
0
        /// <exception cref="System.Exception"></exception>
        public virtual void SetUp()
        {
            storage = new MemoryStorage();
            IEmbeddedObjectContainer db = Db4oEmbedded.OpenFile(Config(), DbPath);

            for (int i = 0; i < NumItems; i++)
            {
                db.Store(new ClassRenameByConfigExcludingOldClassTestCase.OldItem(i));
            }
            db.Close();
        }
        private long StoreItemAndGetCommitTimestamp(IEmbeddedConfiguration config)
        {
            IEmbeddedObjectContainer db = OpenContainer(config);

            CommitTimestampDefragmentTestCase.Item item = new CommitTimestampDefragmentTestCase.Item
                                                              ();
            db.Store(item);
            db.Commit();
            long commitTimestamp = db.Ext().GetObjectInfo(item).GetCommitTimestamp();

            db.Close();
            return(commitTimestamp);
        }
        /// <exception cref="System.IO.IOException"></exception>
        private void CreateDatabase(IList gaps)
        {
            Delete(TempFile());
            IEmbeddedConfiguration   config = NewConfiguration();
            IEmbeddedObjectContainer db     = Db4oEmbedded.OpenFile(config, TempFile());
            IList list = new ArrayList();

            list.Add(new FileUsageStatsTestCase.Child());
            FileUsageStatsTestCase.Item item = new FileUsageStatsTestCase.Item(0, "#0", list);
            db.Store(item);
            db.Commit();
            db.Close();
        }
 private static void StoreItems(PagingMemoryStorage storage)
 {
     IEmbeddedConfiguration config = Db4oEmbedded.NewConfiguration();
     config.File.Storage = storage;
     IEmbeddedObjectContainer container = Db4oEmbedded.OpenFile(config, "benchmark.db4o"
         );
     try
     {
         for (int i = 0; i < ObjectCount; ++i)
         {
             container.Store(new SodaQueryComparatorBenchmark.Item(i, "Item " + i, new SodaQueryComparatorBenchmark.ItemChild
                 ("Child " + i)));
         }
     }
     finally
     {
         container.Close();
     }
 }
Пример #12
0
        private static void MakeAndStoreTwoItemsInTwoContainers(IEmbeddedObjectContainer objectContainer,
            int seriesNumber)
        {
            var evenIndex = 2 * seriesNumber;

            var oddIndex = 1 + evenIndex;

            var fred = new Container {Name = String.Format("Fred_{0}", evenIndex)};

            var itemOne = new Item {Name = String.Format("Odd_{0}", oddIndex)};

            var itemTwo = new Item {Name = String.Format("Even_{0}", evenIndex)};

            itemOne.Container = fred;

            itemTwo.Container = fred;

            {
                objectContainer.Store(itemOne);

                objectContainer.Commit();

                var ethel = new Container {Name = String.Format("Ethel_{0}", evenIndex)};

                var oldContainer = itemTwo.Container;

                itemTwo.Container = ethel;

                if (oldContainer != fred)
                {
                    throw new Exception("No!");
                }

                if (oldContainer.Items.Count() != 1)
                {
                    throw new Exception("No");
                }

                objectContainer.Store(oldContainer);
                objectContainer.Store(itemTwo);
            }
        }
Пример #13
0
        private static void LoadRoutes(IEmbeddedObjectContainer cache, FirefoxDriver driver)
        {
            foreach (var route in cache.AsQueryable <Route>())
            {
                cache.Delete(route);
            }

            driver.Url = "http://www.ryanair.com/en";
            driver.ExecuteScript("window.moveTo(0, 0); window.resizeTo(1280, 1024);");
            var fromPicker = new FromPicker(driver);
            var toPicker   = new ToPicker(driver);

            foreach (var fromCode in fromPicker.GetAirportCodes().ToArray())
            {
                fromPicker.PickAirportByCode(fromCode);

                foreach (var toCode in toPicker.GetAirportCodes().ToArray())
                {
                    var route = new Route(fromCode, toCode);
                    Console.WriteLine(route);
                    cache.Store(route);
                }
            }
        }
Пример #14
0
        private static void LoadFlights(IEmbeddedObjectContainer cache, Route route, FirefoxDriver driver, DateTime when, int weeks)
        {
            var fromFlights = cache.AsQueryable <Flight>()
                              .Where(flight => flight.Source == route.Source && flight.Target == route.Target);

            foreach (var flight in fromFlights)
            {
                cache.Delete(flight);
            }

            var toFlights = cache.AsQueryable <Flight>()
                            .Where(flight => flight.Source == route.Target && flight.Target == route.Source);

            foreach (var flight in toFlights)
            {
                cache.Delete(flight);
            }

            driver.Url = "http://www.ryanair.com/en";
            driver.ExecuteScript("window.moveTo(0, 0); window.resizeTo(1280, 1024);");
            var fromPicker = new FromPicker(driver);
            var toPicker   = new ToPicker(driver);
            var search     = new Search(driver);

            fromPicker.PickAirportByCode(route.Source);
            toPicker.PickAirportByCode(route.Target);
            fromPicker.PickWhen(when);
            toPicker.PickWhen(when);
            search.Submit();

            var fromPlanner = new FromPlanner(driver);
            var toPlanner   = new ToPlanner(driver);

            foreach (var week in Enumerable.Range(1, weeks))
            {
                if (FromPlanner.Exists(driver))
                {
                    foreach (var info in fromPlanner.GetInfos())
                    {
                        var flight = new Flight(route.Source, route.Target, info);
                        Console.WriteLine(flight);
                        cache.Store(flight);
                    }
                }

                if (ToPlanner.Exists(driver))
                {
                    foreach (var info in toPlanner.GetInfos())
                    {
                        var flight = new Flight(route.Target, route.Source, info);
                        Console.WriteLine(flight);
                        cache.Store(flight);
                    }
                }

                if (week < weeks && FromPlanner.Exists(driver) && ToPlanner.Exists(driver))
                {
                    toPlanner.ShowNextWeek();
                    fromPlanner.ShowNextWeek();
                }
            }
        }
Пример #15
0
        public void Create(Person person)
        {
            _context.Store(person);
            _context.Store(person.Children);

            if (person.MotherName != null)
            {
                var mother = Get(person.MotherName);
                mother.Children.Add(person.Name);
                _context.Store(mother.Children);
            }

            if (person.FatherName != null)
            {
                var father = Get(person.FatherName);
                father.Children.Add(person.Name);
                _context.Store(father.Children);
            }

            _context.Commit();
        }
Пример #16
0
 public void Insert(IEntity entity)
 {
     _container.Store(entity);
 }
Пример #17
0
 public void Save(DtoLicensePlateInfo licensePlateInfo)
 {
     _db4oContainer.Store(licensePlateInfo);
     _db4oContainer.Commit();
 }
Пример #18
0
 public void Create(ImageInfo info)
 {
     db.Store(info);
     db.Commit();
 }
Пример #19
0
 public async Task Save <T>(T entity)
 {
     await Task.Run(() => Container.Store(entity));
 }