示例#1
0
        public void Test_InsertRow()
        {
            // Clear Platform table
            string qry = "DELETE FROM Platform";

            CSqlDB.Instance.Execute(qry);

            // Read from database (should fail)
            CTest_SelectQry qrySel = new CTest_SelectQry();

            qrySel.PlatformID = 1;
            Assert.AreEqual(qrySel.Select(), SQLiteErrorCode.NotFound);

            // Insert into database
            CTest_InsertQry qryIns = new CTest_InsertQry();

            qryIns.PlatformID  = 1;
            qryIns.Name        = "test";
            qryIns.Description = "PlatformID 1";
            Assert.AreEqual(qryIns.Insert(), SQLiteErrorCode.Ok);

            // Try again
            qrySel.PlatformID = 1;
            Assert.AreEqual(qrySel.Select(), SQLiteErrorCode.Ok);
            Assert.AreEqual(qrySel.PlatformID, 1);
            Assert.AreEqual(qrySel.Name, "test");
            Assert.AreEqual(qrySel.Description, "PlatformID 1");
            Assert.IsFalse(qrySel.Fetch()); // Only one row found
        }
示例#2
0
        public void Test_InsertDuplicateValue()
        {
            // Read from database
            CTest_SelectQry qrySel = new CTest_SelectQry();

            qrySel.PlatformID = 1;
            Assert.AreEqual(qrySel.Select(), SQLiteErrorCode.Ok);
            Assert.AreEqual(qrySel.PlatformID, 1);
            Assert.AreEqual(qrySel.Name, "test");
            Assert.AreEqual(qrySel.Description, "PlatformID 1");

            // Insert into database
            CTest_InsertQry qryIns = new CTest_InsertQry();

            qryIns.PlatformID  = 1;
            qryIns.Name        = "test";
            qryIns.Description = "PlatformID 1";
            Assert.AreNotEqual(qryIns.Insert(), SQLiteErrorCode.Ok);
        }