コード例 #1
0
        private void InitialiseDatabase(string databaseFolderPath, bool keepLicenceFile)
        {
            TestSession.DeleteFolderIfExists(databaseFolderPath);
            Directory.CreateDirectory(databaseFolderPath);
            TestSession.CopyLicenceToDatabaseFolder(databaseFolderPath);
            Session = new TestSession(databaseFolderPath);
            Session.BeginUpdate();
            // Registering the persistable types will allow the database to be used without a
            // VelocityDB licence file.
            Schema.Instance.RegisterPersistableTypes(Session);
            Session.Commit();
            // Not documented in the VelocityDB manual, in order for the database to be used
            // without a licence file, we also need to first add one of each entity type,
            // which we can and will delete after removing the licence file from the database.
            // I'm fairly sure this has something to do with the VelocityDB Indexes, as (a) we
            // did not have to do this before Indexes were introduced, and (b) it is still not
            // necessary to do it for Schema, the one persistable type that does not use
            // Indexes. There has to be a better way.
            Data = new TestData(new QueryHelper());
            Session.BeginUpdate();
            AddOneOfEachEntityTypePersisted(Data, Session);
            Session.Commit();
            if (!keepLicenceFile)
            {
                RemoveLicenceFileFromDatabase();
            }
            Session.BeginUpdate();
            DeleteOneOfEachEntityType();
            Session.Commit();
            var databaseFolder = new DirectoryInfo(databaseFolderPath);

            foreach (var file in databaseFolder.GetFiles())
            {
                if (string.Compare(
                        file.Name, "1.odb", StringComparison.OrdinalIgnoreCase) != 0 &&
                    string.Compare(
                        file.Name, "2.odb", StringComparison.OrdinalIgnoreCase) != 0)
                {
                    file.Delete();
                }
            }
        }
コード例 #2
0
 public void Setup()
 {
     QueryHelper = new QueryHelper();
     Data        = new TestData(QueryHelper);
     Session     = new TestSession();
     Session.BeginUpdate();
     Data.AddLocationsPersisted(3, Session);
     Data.AddNewslettersPersisted(4, Session);
     Session.Commit();
     EventList = new EventList {
         Session = Session
     };
 }
コード例 #3
0
 public void Setup()
 {
     QueryHelper = new QueryHelper();
     Data        = new TestData(QueryHelper);
     Session     = new TestSession();
     SetComparer = new SetComparer();
     Session.BeginUpdate();
     Data.AddEventTypesPersisted(1, Session);
     Data.AddNewslettersPersisted(1, Session);
     Data.AddSeriesPersisted(1, Session);
     Data.AddActsPersisted(1, Session);
     Data.AddGenresPersisted(1, Session);
     Session.Commit();
 }
コード例 #4
0
 public void Setup()
 {
     QueryHelper = new QueryHelper();
     Data        = new TestData(QueryHelper);
     Session     = new TestSession();
     Session.BeginUpdate();
     Data.AddEventTypesPersisted(2, Session);
     Data.AddLocationsPersisted(2, Session);
     Data.AddActsPersisted(1, Session);
     Data.AddNewslettersPersisted(3, Session);
     Data.AddSeriesPersisted(2, Session);
     Data.AddEventsPersisted(4, Session, Data.Locations[0]);
     Session.Commit();
     List = new EventList {
         QueryHelper = QueryHelper, Session = Session
     };
 }
コード例 #5
0
 public void Setup()
 {
     QueryHelper = new QueryHelper();
     Data        = new TestData(QueryHelper);
     Session     = new TestSession();
     EditorView  = new MockEditorView(new MockMainGrid(), new MockParentGrid());
     CreateControllers(typeof(EventList));
     CellView = new MockView <ComboBoxCellController>();
     Session.BeginUpdate();
     try {
         Data.AddActsPersisted(3, Session);
         Data.AddEventTypesPersisted(1, Session);
         Data.AddLocationsPersisted(2, Session);
         Data.AddNewslettersPersisted(3, Session);
         Data.AddSeriesPersisted(1, Session);
         Data.AddEventsPersisted(5, Session);
     } finally {
         Session.Commit();
     }
     EditorController.Populate(); // Populate grid
 }