Example #1
0
        //-------------------------------------------------------------------------------------------
        /// <summary>
        /// TestDBI_T_process_area_Write_to_DB -- write itemlist to DB
        /// </summary>
        static void TestDBI_T_process_area_Write_to_DB()
        {
            Console.WriteLine("  --START: TestDBI_T_process_area_Write_to_DB");

            process_area_Table myTable = new process_area_Table();

            myTable.itemList = make_process_area_list_1();
            int iRowsStart = myTable.itemList.Count;

            myTable.Show();
            Util.pause();

            Console.WriteLine("  --before clear SQLServer database table");
            Util.pause();
            myTable.Clear_Database_Table();
            int iRows2 = myTable.CountRows();

            if (iRows2 != 0)
            {
                Util.pause("Error.  iRows=" + iRows2 + " should be zero after Clear_Database_Table()");
            }
            else
            {
                Util.pause("OK.  After Clear_Database_Table()");
            }


            Console.WriteLine("Write the table from RAM the SQLServer  Database table");
            myTable.WriteItemListToDatabase();
            int iRows3 = myTable.CountRows();

            if (iRows3 != iRowsStart)
            {
                Util.pause("Error.  iRows3=" + iRows3 + " should be " + iRowsStart + " after WriteItemListToDatabase");
            }
            else
            {
                Util.pause("OK.  After WriteItemListToDatabase()");
            }

            Console.WriteLine("  --after writing to the SQLServer database table.  examine the table using SSMS");
            Util.pause("visually inspect via SSMS?");

            Console.WriteLine("  --DONE: TestDBI_T_process_area_Write_to_DB");
        }//TestDBI_T_process_area_Write_to_DB
Example #2
0
        /// <summary>
        /// TestDBI_T_process_area_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_process_area_AutoCheck_Update()
        {
            const int OK      = 0;
            int       iResult = OK;

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

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

            myTable1.itemList = new List <process_area>()
            {
                // process_area(int val_processAreaId, int val_projectID, string val_name, string val_text,
                // bool val_active, bool val_hasArtifact, bool val_hasprocess_area, string val_rating, bool val_coverage)
                new process_area(1, 1, "name_1", "text_1", true, true, true, "rating_1", true),
                new process_area(2, 2, "name_1", "text_1", true, true, true, "rating_2", true),
                new process_area(3, 3, "name_1", "text_1", true, true, true, "rating_3", true),
                new process_area(4, 4, "name_1", "text_1", true, true, true, "rating_4", true),
                new process_area(5, 5, "name_1", "text_1", true, true, true, "rating_5", true)
            };
            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
            process_area_Table myTable2 = new process_area_Table();

            myTable2.ReadItemListFromDatabase();

            /// 1.6) Compare tables (myTable1 == myTable2)
            if (!TestDBI_T_process_area_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)
            process_area_Table myTableUpdate = new process_area_Table();

            myTableUpdate.itemList = new List <process_area>()
            {
                // process_area(int val_processAreaId, int val_projectID, string val_name, string val_text,
                // bool val_active, bool val_hasArtifact, bool val_hasprocess_area, string val_rating, bool val_coverage)
                new process_area(1, 1, "name_1", "text_1", true, true, true, "rating_1", true),
                new process_area(2, 2, "name_1", "text_1", true, true, true, "rating_2-update", true),
                new process_area(3, 3, "name_1", "text_1", true, true, true, "rating_3", true),
                new process_area(4, 4, "name_1", "text_1", true, true, true, "rating_4-update", true),
                new process_area(5, 5, "name_1", "text_1", true, true, true, "rating_5", true)
            };


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

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

            myTable3.ReadItemListFromDatabase();


            //1.10) Compare tables.itemLists (myTableUpdate == myTable3)
            if (!TestDBI_T_process_area_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_process_area_AutoCheck_Update()");
            return(iResult);
        }