示例#1
0
        public void DatabaseSetKey()
        {
            int record;

            record = DatabaseStoreStatic.NewRecord();
            DatabaseStoreStatic.SetKey(record, "testing");
            Assert.AreEqual("testing", DatabaseStoreStatic.GetKey(record));
        }
示例#2
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));
        }
示例#3
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);
        }
示例#4
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);
        }
示例#5
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);
        }
示例#6
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);
        }
示例#7
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));
        }
示例#8
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"));
        }