Exemplo n.º 1
0
        public void DataStoreSetUp()
        {
            if (Environment.OSVersion.Platform == PlatformID.Win32NT)
            {
                Environment.SetEnvironmentVariable("BIBTEX_TYPE_LIB", Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\bibliographer\\bibtex_records");
                Environment.SetEnvironmentVariable("BIBTEX_FIELDTYPE_LIB", Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\bibliographer\\bibtex_fields");
                testFilename = Path.GetTempPath() + "\\datastoretest.sqlite";
            }
            else
            {
                Environment.SetEnvironmentVariable("BIBTEX_TYPE_LIB", Environment.GetEnvironmentVariable("HOME") + "/.config/bibliographer/bibtex_records");
                Environment.SetEnvironmentVariable("BIBTEX_FIELDTYPE_LIB", Environment.GetEnvironmentVariable("HOME") + "/.config/bibliographer/bibtex_fields");
                testFilename = "/tmp/datastoretest.sqlite";
            }
            BibtexRecordTypeLibrary.Load();
            BibtexRecordFieldTypeLibrary.Load();

            // Delete testfilename if it exists so that we can check correct creation
            if (File.Exists(testFilename))
            {
                File.Delete(testFilename);
            }
            Assert.IsFalse(File.Exists(testFilename), "File: " + testFilename + " exists prior to databaseStore constructor.");

            DatabaseStoreStatic.Initialize(testFilename);
            Assert.IsTrue(File.Exists(testFilename), "File: " + testFilename + " has been created by the databaseStore constructor.");
        }
Exemplo n.º 2
0
        public void DatabaseSetKey()
        {
            int record;

            record = DatabaseStoreStatic.NewRecord();
            DatabaseStoreStatic.SetKey(record, "testing");
            Assert.AreEqual("testing", DatabaseStoreStatic.GetKey(record));
        }
Exemplo n.º 3
0
        public void SetKey(string key)
        {
            if (DatabaseStoreStatic.GetKey(RecordId) != key)
            {
                Enter(this);
                WriteLine(5, "Key set: {0}", key);
                DatabaseStoreStatic.SetKey(RecordId, key);
                Exit(this);

                OnRecordModified(new EventArgs());
            }
        }
Exemplo n.º 4
0
        public void DatabaseDeleteField()
        {
            int record;

            record = DatabaseStoreStatic.NewRecord();
            DatabaseStoreStatic.SetField(record, "author", "first author");
            Assert.AreEqual("first author", DatabaseStoreStatic.GetField(record, "author"));
            DatabaseStoreStatic.DeleteField(record, "author");
            Assert.AreEqual("", DatabaseStoreStatic.GetField(record, "author"));
            DatabaseStoreStatic.DeleteRecord(record);
            Assert.Throws <NoResultException> (() => DatabaseStoreStatic.GetKey(record));
        }
Exemplo n.º 5
0
        public void DatabaseGetField()
        {
            int record;

            record = DatabaseStoreStatic.NewRecord();
            Assert.IsFalse(DatabaseStoreStatic.HasField(record, "author"));
            DatabaseStoreStatic.SetField(record, "author", "first author");
            Assert.IsTrue(DatabaseStoreStatic.HasField(record, "author"));
            DatabaseStoreStatic.DeleteField(record, "author");
            Assert.IsFalse(DatabaseStoreStatic.HasField(record, "author"));
            DatabaseStoreStatic.DeleteRecord(record);
        }
Exemplo n.º 6
0
        public void DatabaseSetField()
        {
            int record;

            record = DatabaseStoreStatic.NewRecord();
            DatabaseStoreStatic.SetField(record, "author", "first author");
            Assert.AreEqual("first author", DatabaseStoreStatic.GetField(record, "author"));
            DatabaseStoreStatic.SetField(record, "author", "first author and second author");
            Assert.AreEqual("first author and second author", DatabaseStoreStatic.GetField(record, "author"));
            DatabaseStoreStatic.DeleteField(record, "author");
            DatabaseStoreStatic.DeleteRecord(record);
        }
Exemplo n.º 7
0
        public void DatabaseNewRecord()
        {
            int result;

            result = DatabaseStoreStatic.NewRecord();
            Assert.AreEqual(1, result);
            result = DatabaseStoreStatic.NewRecord("test");
            Assert.AreEqual(2, result);
            Assert.AreEqual("test", DatabaseStoreStatic.GetKey(result));
            DatabaseStoreStatic.DeleteRecord(1);
            DatabaseStoreStatic.DeleteRecord(2);
        }
Exemplo n.º 8
0
        public void DatabaseGetRecords()
        {
            List <int> result;

            result = DatabaseStoreStatic.GetRecords();
            Assert.AreEqual(0, result.Count);
            DatabaseStoreStatic.NewRecord();
            result = DatabaseStoreStatic.GetRecords();
            Assert.AreEqual(1, result.Count);
            DatabaseStoreStatic.DeleteRecord(1);
            result = DatabaseStoreStatic.GetRecords();
            Assert.AreEqual(0, result.Count);
        }
Exemplo n.º 9
0
        public void DatabaseGetFieldNames()
        {
            int record;

            record = DatabaseStoreStatic.NewRecord();
            Assert.IsEmpty(DatabaseStoreStatic.GetFieldNames(record));
            DatabaseStoreStatic.SetField(record, "author", "first author");
            DatabaseStoreStatic.SetField(record, "title", "title");
            Assert.AreEqual(2, DatabaseStoreStatic.GetFieldNames(record).Count);
            Assert.IsTrue(DatabaseStoreStatic.GetFieldNames(record).Contains("author"));
            Assert.IsTrue(DatabaseStoreStatic.GetFieldNames(record).Contains("title"));
            Assert.IsFalse(DatabaseStoreStatic.GetFieldNames(record).Contains("journal"));
            DatabaseStoreStatic.DeleteRecord(record);
            Assert.IsEmpty(DatabaseStoreStatic.GetFieldNames(record));
        }
Exemplo n.º 10
0
        public void DatabaseDeleteRecord()
        {
            int record;

            record = DatabaseStoreStatic.NewRecord("test");
            DatabaseStoreStatic.SetField(record, "author", "first author");
            DatabaseStoreStatic.SetFilename(record, "file://testuri");
            Assert.DoesNotThrow(() => DatabaseStoreStatic.GetKey(record));
            Assert.AreEqual("test", DatabaseStoreStatic.GetKey(record));
            Assert.DoesNotThrow(() => DatabaseStoreStatic.GetField(record, "author"));
            Assert.AreEqual("first author", DatabaseStoreStatic.GetField(record, "author"));
            Assert.AreEqual("file://testuri", DatabaseStoreStatic.GetFilename(record));
            DatabaseStoreStatic.DeleteRecord(record);
            Assert.Throws <NoResultException> (() => DatabaseStoreStatic.GetKey(record));
            Assert.AreEqual("", DatabaseStoreStatic.GetFilename(record));
            Assert.AreEqual("", DatabaseStoreStatic.GetField(record, "author"));
        }
Exemplo n.º 11
0
 public BibtexRecord(int databaseId)
 {
     RecordId = databaseId;
     SetCustomDataField("indexData", DatabaseStoreStatic.GetSearchData(databaseId));
 }
Exemplo n.º 12
0
 public string GetKey()
 {
     return(DatabaseStoreStatic.GetKey(RecordId));
 }