Exemplo n.º 1
0
        }//TestDBI_T_interview_question_Write_to_DB

        //-------------------------------------------------------------------------------------------
        static void TestDBI_T_interview_question_Read_from_DB()
        {
            Console.WriteLine("  --START: TestDBI_T_interview_question_Read_from_DB");
            interview_question_Table myTable = new interview_question_Table();

            int iRows = myTable.CountRows();

            Console.WriteLine("myTable.CountRows = " + iRows.ToString());

            Console.WriteLine("Fill the table in RAM from the SQLServer Database table");
            myTable.ReadItemListFromDatabase();
            myTable.Show();
            if (myTable.itemList.Count != iRows)
            {
                Console.WriteLine("Error.  myTable.itemList.Count != myTable.CountRows." + " should be the same ReadItemListFromDatabase ()");
            }
            else
            {
                Console.WriteLine("OK.  After ReadItemListFromDatabase()");
            }

            Util.pause();
            Console.WriteLine("  --DONE: TestDBI_T_interview_question_Read_from_DB");
        }//TestDBI_T_interview_question_Read_from_DB
Exemplo n.º 2
0
        /// <summary>
        /// TestDBI_T_interview_question_AutoCheck_Update - Update Item List;
        /// 1.1) Create test data: myTable1;
        /// 1.2) Clear DBTable;
        /// 1.3) Write myTable1 to DBTable;
        /// 1.4) Get DBTable.CountRows, compare (myTable1.itemList.Count == DBTable.CountRows)
        /// 1.5) Read myTable2 from DBTable
        /// 1.6) Compare tables (myTable1 == myTable2)
        /// 1.7) Create the update table (myTableUpdate)
        /// 1.8) Update TableDB
        /// 1.9) Read myTable3
        /// 1.10) Compare tables.itemLists(myTableUpdate == myTable3)
        /// </summary>
        /// <returns></returns>
        static int TestDBI_T_interview_question_AutoCheck_Update()
        {
            const int OK      = 0;
            int       iResult = OK;

            Console.WriteLine("START: TestDBI_T_interview_question_AutoCheck_Update()");

            // 1.1) CreateTestData1: myTable1
            interview_question_Table myTable1 = new interview_question_Table();

            myTable1.itemList = new List <interview_question>()
            {
                //  interview_question(String val_interviewQuestions, String val_questionNotes, int val_sessionId)
                new interview_question("question_1", "notes_1", 1),
                new interview_question("question_1", "notes_1", 2),
                new interview_question("question_1", "notes_1", 3),
                new interview_question("question_1", "notes_1", 4),
                new interview_question("question_1", "notes_1", 5)
            };
            int iRowsAtStart = myTable1.itemList.Count;

            // 1.2) ClearDBTable
            myTable1.Clear_Database_Table();
            int iRowsAfterClear = myTable1.CountRows();

            if (iRowsAfterClear != 0)
            {
                iResult = -1;
                Console.WriteLine("Error: DBTable should be empty after Clear_Database_Table.  iRowsAfterClear=" + iRowsAfterClear);
                return(iResult);
            }

            // 1.3) Write myTable1 to DBTable
            myTable1.WriteItemListToDatabase();

            // 1.4) Get DBTable.CountRows, compare (myTable1.itemList.Count == DBTable.CountRows)
            int iRowsAfterWriteItemListr = myTable1.CountRows();

            if (iRowsAfterWriteItemListr != iRowsAtStart)
            {
                iResult = -1;
                Console.WriteLine("Error: DBTable should be same as iRowsAtStart after WriteItemListToDatabase.  iRowsAfterWriteItemListr=" + iRowsAfterWriteItemListr);
                return(iResult);
            }

            /// 1.5) Read myTable2 from DBTable
            interview_question_Table myTable2 = new interview_question_Table();

            myTable2.ReadItemListFromDatabase();

            /// 1.6) Compare tables (myTable1 == myTable2)
            if (!TestDBI_T_interview_question_CompareLists(myTable1.itemList, myTable2.itemList))
            {
                iResult = -1;
                Console.WriteLine("Error: DBTable should be same as test data");
                return(iResult);
            }

            /// 1.7) Create the update table (myTableUpdate)
            interview_question_Table myTableUpdate = new interview_question_Table();

            myTableUpdate.itemList = new List <interview_question>()
            {
                //  interview_question(String val_interviewQuestions, String val_questionNotes, int val_sessionId)
                new interview_question("question_1", "notes_1", 1),
                new interview_question("question_1", "notes_1", 2),
                new interview_question("question_1", "notes_1", 3),
                new interview_question("question_1", "notes_1", 4),
                new interview_question("question_1", "notes_1", 5)
            };


            //1.8) Update TableDB
            myTableUpdate.UpdateItemListToDatabase();

            //1.9) Read myTable3
            interview_question_Table myTable3 = new interview_question_Table();

            myTable3.ReadItemListFromDatabase();


            //1.10) Compare tables.itemLists (myTableUpdate == myTable3)
            if (!TestDBI_T_interview_question_CompareLists(myTableUpdate.itemList, myTable3.itemList))
            {
                iResult = -1;
                Console.WriteLine("Error: DBTable should be same as the update table");
                return(iResult);
            }


            Console.WriteLine("DONE: TestDBI_T_interview_question_AutoCheck_Update()");
            return(iResult);
        }