예제 #1
0
        public void MonthlySales_OneSaleWrongDate()
        {
            DBConnection_Accessor db = new DBConnection_Accessor();
            StatsCalc_Accessor    st = new StatsCalc_Accessor(db.GetDB());
            Delete_Accessor       d  = new Delete_Accessor(db.GetDB());
            TestingFunctions      tf = new TestingFunctions(db.GetDB());

            try
            {
                tf.DeleteSale("3", "121", "9");
            }
            catch (Exception e)
            {
            }

            String[] sale = new String[] { "3", "121", "9", "4/10/2008", "34000" };
            MakeSale sa   = new MakeSale(sale, db.GetDB());

            sa.CreateSale();

            String s = st.MonthlySales("11", "2003");

            Assert.IsTrue(int.Parse(s) == 0);

            tf.DeleteSale("3", "121", "9");
        }
예제 #2
0
        public void EmployeeProgress_NormalPath()
        {
            DBConnection_Accessor db = new DBConnection_Accessor();
            StatsCalc_Accessor st = new StatsCalc_Accessor(db.GetDB());
            Delete_Accessor d = new Delete_Accessor(db.GetDB());
            TestingFunctions tf = new TestingFunctions(db.GetDB());
            try
            {
                tf.DeleteSale("3", "121", "9");
            }
            catch (Exception e)
            {
            }

            String[] sale = new String[] { "3", "121", "9", "4/10/2008", "34000" };
            MakeSale sa = new MakeSale(sale, db.GetDB());
            sa.CreateSale();

            DataTable dt = st.CalculateProgress();
            Double actual = (Double)dt.Rows[0].ItemArray[2];
            Double expected = 34000;
            Assert.IsTrue(actual == expected);

            tf.DeleteSale("3", "121", "9");
        }
예제 #3
0
        public void SearchSale_NormalPath()
        {
            DBConnection_Accessor   connection = new DBConnection_Accessor();
            SearchFunction_Accessor SF         = new SearchFunction_Accessor(connection.GetDB());
            DataTable        dt = new DataTable();
            TestingFunctions tf = new TestingFunctions(connection.GetDB());

            try
            {
                tf.DeleteSale("3", "121", "9");
            }
            catch (Exception e)
            {
            }


            String[] sale = new String[] { "3", "121", "9", "4/10/2008", "34000" };
            MakeSale sa   = new MakeSale(sale, connection.GetDB());

            sa.CreateSale();

            try
            {
                dt = SF.SearchSale("9", "121", "3");
            }
            catch (OleDbException ex)
            {
                throw ex;
            }


            Assert.IsTrue(dt.Rows.Count == 1);
            tf.DeleteSale("3", "121", "9");
        }
예제 #4
0
        public void RevenueTest_DecimalSales()
        {
            DBConnection_Accessor db = new DBConnection_Accessor();
            StatsCalc_Accessor    st = new StatsCalc_Accessor(db.GetDB());
            Delete_Accessor       d  = new Delete_Accessor(db.GetDB());
            TestingFunctions      tf = new TestingFunctions(db.GetDB());

            try
            {
                tf.DeleteSale("3", "121", "9");
                tf.DeleteSale("7", "121", "9");
            }
            catch (Exception)
            {
            }


            String[] sale = new String[] { "3", "121", "9", "3/3/3", "1200.3" };
            MakeSale sa   = new MakeSale(sale, db.GetDB());

            sa.CreateSale();

            String[] sale2 = new String[] { "7", "121", "9", "3/3/3", "1200.75" };
            MakeSale sa2   = new MakeSale(sale2, db.GetDB());

            sa2.CreateSale();

            String s = st.Revenue();

            Assert.IsTrue(double.Parse(s) == 2401.05);

            tf.DeleteSale("3", "121", "9");
            tf.DeleteSale("7", "121", "9");
        }
예제 #5
0
        public void AddSale_Duplicate()
        {
            DBConnection_Accessor db = new DBConnection_Accessor();
            StatsCalc_Accessor st = new StatsCalc_Accessor(db.GetDB());
            Delete_Accessor d = new Delete_Accessor(db.GetDB());
            TestingFunctions tf = new TestingFunctions(db.GetDB());
            try
            {
                tf.DeleteSale("3", "121", "9");
            }
            catch (Exception e)
            {
            }

            String[] sale = new String[] { "3", "121", "9", "4/10/2008", "34000" };
            MakeSale sa = new MakeSale(sale, db.GetDB());
            sa.CreateSale();
            sa.CreateSale();

            try
            {
                tf.DeleteSale("3", "121", "9");
            }
            catch (Exception e)
            {
            }
        }
예제 #6
0
        public void EmployeeProgress_NormalPath()
        {
            DBConnection_Accessor db = new DBConnection_Accessor();
            StatsCalc_Accessor    st = new StatsCalc_Accessor(db.GetDB());
            Delete_Accessor       d  = new Delete_Accessor(db.GetDB());
            TestingFunctions      tf = new TestingFunctions(db.GetDB());

            try
            {
                tf.DeleteSale("3", "121", "9");
            }
            catch (Exception e)
            {
            }


            String[] sale = new String[] { "3", "121", "9", "4/10/2008", "34000" };
            MakeSale sa   = new MakeSale(sale, db.GetDB());

            sa.CreateSale();

            DataTable dt       = st.CalculateProgress();
            Double    actual   = (Double)dt.Rows[0].ItemArray[2];
            Double    expected = 34000;

            Assert.IsTrue(actual == expected);

            tf.DeleteSale("3", "121", "9");
        }
예제 #7
0
        public void RevenueTest_OneSale()
        {
            DBConnection_Accessor db = new DBConnection_Accessor();
            StatsCalc_Accessor    st = new StatsCalc_Accessor(db.GetDB());
            Delete_Accessor       d  = new Delete_Accessor(db.GetDB());
            TestingFunctions      tf = new TestingFunctions(db.GetDB());

            try
            {
                tf.DeleteSale("3", "121", "9");
            }
            catch (Exception)
            {
            }

            String[] sale = new String[] { "3", "121", "9", "3/3/3", "1200" };
            MakeSale sa   = new MakeSale(sale, db.GetDB());

            sa.CreateSale();

            String s = st.Revenue();

            Assert.IsTrue(int.Parse(s) == 1200);



            tf.DeleteSale("3", "121", "9");
        }
예제 #8
0
        public void AddSale_CIDNonExistent()
        {
            DBConnection_Accessor db = new DBConnection_Accessor();
            StatsCalc_Accessor    st = new StatsCalc_Accessor(db.GetDB());
            Delete_Accessor       d  = new Delete_Accessor(db.GetDB());
            TestingFunctions      tf = new TestingFunctions(db.GetDB());

            try
            {
                tf.DeleteSale("3", "121", "9");
            }
            catch (Exception e)
            {
            }

            String[] sale = new String[] { "3", "99999", "9", "4/10/2008", "34000" };
            MakeSale sa   = new MakeSale(sale, db.GetDB());

            sa.CreateSale();

            try
            {
                tf.DeleteSale("3", "99999", "0");
            }
            catch (Exception e)
            {
            }
        }
예제 #9
0
        public void RevenueTest_MultipleSales()
        {
            DBConnection_Accessor db = new DBConnection_Accessor();
            StatsCalc_Accessor st = new StatsCalc_Accessor(db.GetDB());
            Delete_Accessor d = new Delete_Accessor(db.GetDB());
            TestingFunctions tf = new TestingFunctions(db.GetDB());
            try
            {
                tf.DeleteSale("3", "121", "9");
                tf.DeleteSale("7", "121", "9");
            }
            catch (Exception)
            {

            }

            String[] sale = new String[] { "3", "121", "9", "3/3/3", "1200" };
            MakeSale sa = new MakeSale(sale, db.GetDB());
            sa.CreateSale();

            String[] sale2 = new String[] { "7", "121", "9", "3/3/3", "1200" };
            MakeSale sa2 = new MakeSale(sale2, db.GetDB());
            sa2.CreateSale();

            String s = st.Revenue();

            Assert.IsTrue(int.Parse(s) == 2400);

            tf.DeleteSale("3", "121", "9");
            tf.DeleteSale("7", "121", "9");
        }
예제 #10
0
        public void DeleteVehicle_ExistsInSale()
        {
            DBConnection_Accessor connection = new DBConnection_Accessor();
            Delete_Accessor       d          = new Delete_Accessor(connection.GetDB());

            TestingFunctions tf = new TestingFunctions(connection.GetDB());

            try
            {
                tf.DeleteSale("112", "121", "9");
            }
            catch (Exception e)
            {
            }
            try
            {
                d.DeleteVehicle(112);
            }
            catch (Exception e)
            {
            }
            String[] D = new String[] { "112", "1", "1", "1", "1", "1" };

            MakeVehicle_Accessor veh = new MakeVehicle_Accessor(D, connection.GetDB());

            veh.CreateVehicle();
            MakeCar_Accessor car = new MakeCar_Accessor("112", "smart car", connection.GetDB());

            car.CreateCar();

            String[] sale = new String[] { "112", "121", "9", "4/10/2008", "34000" };
            MakeSale sa   = new MakeSale(sale, connection.GetDB());

            sa.CreateSale();

            try
            {
                d.DeleteVehicle(112);
            }
            catch (Exception ex)
            {
                try
                {
                    tf.DeleteSale("112", "121", "9");
                }
                catch (Exception e)
                {
                }

                throw ex;
            }
        }
예제 #11
0
        public void MonthlySales_OneSale()
        {
            DBConnection_Accessor db = new DBConnection_Accessor();
            StatsCalc_Accessor st = new StatsCalc_Accessor(db.GetDB());
            Delete_Accessor d = new Delete_Accessor(db.GetDB());
            TestingFunctions tf = new TestingFunctions(db.GetDB());
            try
            {
                tf.DeleteSale("3", "121", "9");
            }
            catch (Exception e)
            {
            }

            String[] sale = new String[] { "3", "121", "9", "4/10/2008", "34000" };
            MakeSale sa = new MakeSale(sale, db.GetDB());
            sa.CreateSale();

            String s = st.MonthlySales("4", "2008");
            Assert.IsTrue(int.Parse(s) == 34000);

            tf.DeleteSale("3", "121", "9");
        }
예제 #12
0
        public void DeleteVehicle_ExistsInSale()
        {
            DBConnection_Accessor connection = new DBConnection_Accessor();
            Delete_Accessor d = new Delete_Accessor(connection.GetDB());

            TestingFunctions tf = new TestingFunctions(connection.GetDB());
            try
            {
                tf.DeleteSale("112", "121", "9");
            }
            catch (Exception e)
            {
            }
            try
            {
                d.DeleteVehicle(112);
            }
            catch (Exception e)
            {
            }
            String[] D = new String[] { "112", "1", "1", "1", "1", "1" };

            MakeVehicle_Accessor veh = new MakeVehicle_Accessor(D, connection.GetDB());
            veh.CreateVehicle();
            MakeCar_Accessor car = new MakeCar_Accessor("112", "smart car", connection.GetDB());
            car.CreateCar();

            String[] sale = new String[] { "112", "121", "9", "4/10/2008", "34000" };
            MakeSale sa = new MakeSale(sale, connection.GetDB());
            sa.CreateSale();

            try
            {
                d.DeleteVehicle(112);
            }
            catch (Exception ex)
            {
                try
                {
                    tf.DeleteSale("112", "121", "9");
                }
                catch (Exception e)
                {
                }

                throw ex;
            }
        }
예제 #13
0
        public void SearchSale_NormalPath()
        {
            DBConnection_Accessor connection = new DBConnection_Accessor();
            SearchFunction_Accessor SF = new SearchFunction_Accessor(connection.GetDB());
            DataTable dt = new DataTable();
            TestingFunctions tf = new TestingFunctions(connection.GetDB());

            try
            {
                tf.DeleteSale("3", "121", "9");
            }
            catch (Exception e)
            {
            }

            String[] sale = new String[] { "3", "121", "9", "4/10/2008", "34000" };
            MakeSale sa = new MakeSale(sale, connection.GetDB());
            sa.CreateSale();

            try
            {
                dt = SF.SearchSale("9", "121", "3");
            }
            catch (OleDbException ex)
            {
                throw ex;
            }

            Assert.IsTrue(dt.Rows.Count == 1);
            tf.DeleteSale("3", "121", "9");
        }