コード例 #1
0
        public void AddShopTest()
        {
            ShopsManager_Accessor target = new ShopsManager_Accessor(); // TODO: Initialize to an appropriate value
            Hypermarket_Admin_Management_Tool._1_Model.DBManager_Accessor DBController =
                                                        Hypermarket_Admin_Management_Tool._1_Model.DBManager_Accessor.getInstance();
            DataTable expectedResult = new DataTable();
            expectedResult.Columns.Add("ShopID", typeof(string));  //define the attributes
            expectedResult.Columns.Add("Country", typeof(string));
            expectedResult.Columns.Add("Location", typeof(string));
            expectedResult.Columns.Add("Contact", typeof(string));

            string shopID = "1234"; // TODO: Initialize to an appropriate value
            string country = "Singapore"; // TODO: Initialize to an appropriate value
            string location = "TestingLocation"; // TODO: Initialize to an appropriate value
            string contact = "+6594326098"; // TODO: Initialize to an appropriate value
            DBController.DeleteShop(shopID);
            expectedResult.Rows.Add(shopID, country, location, contact);
            target.AddShop(shopID, country, location, contact);   //test on AddShop
            DataTable targetResult = DBController.FetchShop();
            DataRow expectedRow = expectedResult.Rows[expectedResult.Rows.Count - 1];
            DataRow targetRow = targetResult.Rows[targetResult.Rows.Count - 1];
            Assert.AreEqual(expectedRow["ShopID"],targetRow["ShopID"]);
            Assert.AreEqual(expectedRow["Country"], targetRow["Country"]);
            Assert.AreEqual(expectedRow["Location"], targetRow["Location"]);
            Assert.AreEqual(expectedRow["Contact"], targetRow["Contact"]);
            DBController.DeleteShop(shopID);
        }
コード例 #2
0
        public void DeleteShopTest()
        {
            ShopsManager_Accessor target = new ShopsManager_Accessor(); // TODO: Initialize to an appropriate value
            Hypermarket_Admin_Management_Tool._1_Model.DBManager_Accessor DBController =
                                                       Hypermarket_Admin_Management_Tool._1_Model.DBManager_Accessor.getInstance();
            DataTable expectedResult = new DataTable();
            expectedResult = DBController.FetchShop();   //featch original shop table

            string shopID = "1234"; // TODO: Initialize to an appropriate value
            string country = "Singapore"; // TODO: Initialize to an appropriate value
            string location = "TestingLocation"; // TODO: Initialize to an appropriate value
            string contact = "+6594326098"; // TODO: Initialize to an appropriate value
            DBController.DeleteShop(shopID);
            target.AddShop(shopID, country, location, contact);
            target.DeleteShop(shopID);
            DataTable targetResult = DBController.FetchShop();
            Assert.AreEqual(expectedResult.Rows.Count, targetResult.Rows.Count);
        }
コード例 #3
0
        public void GenerateNextAvailableShopIDTest()
        {
            ShopsManager_Accessor target = new ShopsManager_Accessor(); // TODO: Initialize to an appropriate value
            Hypermarket_Admin_Management_Tool._1_Model.DBManager_Accessor DBController =
                                                       Hypermarket_Admin_Management_Tool._1_Model.DBManager_Accessor.getInstance();
            //first test
            DBController.DeleteShop("1");
            DBController.DeleteShop("1234");
            string shopID = "1234"; // TODO: Initialize to an appropriate value
            string country = "Singapore"; // TODO: Initialize to an appropriate value
            string location = "TestingLocation"; // TODO: Initialize to an appropriate value
            string contact = "+6594326098"; // TODO: Initialize to an appropriate value
            target.AddShop(shopID, country, location, contact);

            DataTable targetResult = DBController.FetchShop();
            string AddedNewShopID = target.GenerateNextAvailableShopID();
            Assert.AreEqual("1", AddedNewShopID);

            //second test
            shopID = "1";
            DBController.DeleteShop(shopID);
            target.AddShop(shopID, country, location, contact);
            targetResult = DBController.FetchShop();
            AddedNewShopID = target.GenerateNextAvailableShopID();
            Assert.AreEqual("2", AddedNewShopID);
            DBController.DeleteShop("1");
            DBController.DeleteShop("1234");

            //third test
            AddedNewShopID = target.GenerateNextAvailableShopID();
            Assert.AreEqual("1", AddedNewShopID);
        }
コード例 #4
0
        public void UpdateShopTest()
        {
            ShopsManager_Accessor target = new ShopsManager_Accessor(); // TODO: Initialize to an appropriate value
            Hypermarket_Admin_Management_Tool._1_Model.DBManager_Accessor DBController =
                                                       Hypermarket_Admin_Management_Tool._1_Model.DBManager_Accessor.getInstance();
            string shopID = "1234"; // TODO: Initialize to an appropriate value
            string country = "Singapore"; // TODO: Initialize to an appropriate value
            string location = "TestingLocation"; // TODO: Initialize to an appropriate value
            string contact = "+6594326098"; // TODO: Initialize to an appropriate value
            DBController.DeleteShop(shopID);
            target.AddShop(shopID, country, location, contact);

            target.UpdateShop("1234", "Singapore", "TestingLocation", "+6594326099");
            DataTable targetResult = DBController.FetchShop();
            DataRow targetRow = targetResult.Select("ShopID=1234")[0];
            Assert.AreEqual("1234", targetRow["ShopID"]);
            Assert.AreEqual("Singapore", targetRow["Country"]);
            Assert.AreEqual("TestingLocation", targetRow["Location"]);
            Assert.AreEqual("+6594326099", targetRow["Contact"]);
            DBController.DeleteShop(shopID);
        }
コード例 #5
0
 public void FetchShopTest()
 {
     ShopsManager_Accessor target = new ShopsManager_Accessor(); // TODO: Initialize to an appropriate value
     Hypermarket_Admin_Management_Tool._1_Model.DBManager_Accessor DBController =
                                                Hypermarket_Admin_Management_Tool._1_Model.DBManager_Accessor.getInstance();
     DataTable expectedResult = DBController.FetchShop();
     DataTable targetResult = target.FetchShop();
     Assert.AreEqual(targetResult.Rows.Count, expectedResult.Rows.Count);
 }