コード例 #1
0
ファイル: TestDBI_affirmation.cs プロジェクト: CSSA/TestDBI
        //-------------------------------------------------------------------------------------------
        /// <summary>
        /// TestDBI_T_affirmation_Write_to_DB -- write itemlist to DB
        /// </summary>
        static void TestDBI_T_affirmation_Write_to_DB()
        {
            Console.WriteLine("  --START: TestDBI_T_affirmation_Write_to_DB");

            affirmation_Table myTable = new affirmation_Table();

            myTable.itemList = make_affirmation_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_affirmation_Write_to_DB");
        }//TestDBI_T_affirmation_Write_to_DB
コード例 #2
0
ファイル: TestDBI_affirmation.cs プロジェクト: CSSA/TestDBI
        static void TestDBI_T_affirmation_Write_Read_T6()
        {
            //create demo data: table1
            affirmation_Table myTable1 = new affirmation_Table();

            myTable1.itemList = make_affirmation_list_1();
            int iRows1 = myTable1.itemList.Count;

            myTable1.Show();

            //write to DB
            myTable1.WriteItemListToDatabase();

            //create demo table: table2, read from DB
            affirmation_Table myTable2 = new affirmation_Table();
            int iRows2 = myTable2.itemList.Count;

            if (iRows1 != iRows2)
            {
                Console.WriteLine("Error. row counts don't match");
            }
            else
            {
                Console.WriteLine("OK.  row countsmatch()");
            }

            //compare table1 & table2
            int iResult = CompareLists(myTable1.itemList, myTable2.itemList);

            if (iResult != 0)
            {
                Console.WriteLine("Error. itemLists don't match");
            }
            else
            {
                Console.WriteLine("OK.  itemLists match");
            }
            Util.pause();
        }
コード例 #3
0
ファイル: TestDBI_affirmation.cs プロジェクト: CSSA/TestDBI
        /// <summary>
        /// TestDBI_T_affirmation_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_affirmation_AutoCheck_Update()
        {
            const int OK      = 0;
            int       iResult = OK;

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

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

            myTable1.itemList = new List <affirmation>()
            {
                // affirmation(int val_affirmationId, String val_affirmationName, String val_affirmationType,
                //String val_specificGoal, String val_specificPractice, String val_genericGoal, String val_genericPractice, String val_processArea, int projectId)
                new  affirmation(1, "affName_1", "affType_2", "sg_3", "sp_4", "gg_5", "gp_6", "pa_7", 1),
                new  affirmation(2, "affName_1", "affType_2", "sg_3", "sp_4", "gg_5", "gp_6", "pa_7", 2),
                new  affirmation(3, "affName_1", "affType_2", "sg_3", "sp_4", "gg_5", "gp_6", "pa_7", 3),
                new  affirmation(4, "affName_1", "affType_2", "sg_3", "sp_4", "gg_5", "gp_6", "pa_7", 4),
                new  affirmation(5, "affName_1", "affType_2", "sg_3", "sp_4", "gg_5", "gp_6", "pa_7", 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
            affirmation_Table myTable2 = new affirmation_Table();

            myTable2.ReadItemListFromDatabase();

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

            myTableUpdate.itemList = new List <affirmation>()
            {
                // affirmation(int val_affirmationId, String val_affirmationName, String val_affirmationType,
                //String val_specificGoal, String val_specificPractice, String val_genericGoal, String val_genericPractice, String val_processArea, int projectId)
                new  affirmation(1, "affName_1", "affType_2", "sg_3", "sp_4", "gg_5", "gp_6", "pa_7", 1),
                new  affirmation(2, "affName_1", "affType_2", "sg_3", "sp_4", "gg_5", "gp_6", "pa_7-update", 2),
                new  affirmation(3, "affName_1", "affType_2", "sg_3", "sp_4", "gg_5", "gp_6", "pa_7", 3),
                new  affirmation(4, "affName_1", "affType_2", "sg_3", "sp_4", "gg_5", "gp_6", "pa_7-update", 4),
                new  affirmation(5, "affName_1", "affType_2", "sg_3", "sp_4", "gg_5", "gp_6", "pa_7", 5),
            };


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

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

            myTable3.ReadItemListFromDatabase();


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