public void AddManufacturerTest() { ProductManager target = new ProductManager(); // 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("ManufacturerName", typeof(string)); //define the attributes expectedResult.Columns.Add("Address", typeof(string)); expectedResult.Columns.Add("Country", typeof(string)); expectedResult.Columns.Add("Contact", typeof(string)); string manufacturerName = "ZL"; // TODO: Initialize to an appropriate value string address = "Tester"; // TODO: Initialize to an appropriate value string country = "Singapore"; // TODO: Initialize to an appropriate value string contact = "+6593425678"; // TODO: Initialize to an appropriate value DBController.DeleteManufacturer("ZL"); target.AddManufacturer(manufacturerName, address, country, contact); expectedResult.Rows.Add(manufacturerName, address, country, contact); DataTable targetResult = DBController.FetchManufacturer(); DataRow expectedRow = expectedResult.Rows[expectedResult.Rows.Count - 1]; DataRow targetRow = targetResult.Rows[targetResult.Rows.Count - 1]; Assert.AreEqual(expectedRow["ManufacturerName"], targetRow["ManufacturerName"]); Assert.AreEqual(expectedRow["Address"], targetRow["Address"]); Assert.AreEqual(expectedRow["Country"], targetRow["Country"]); Assert.AreEqual(expectedRow["Contact"], targetRow["Contact"]); DBController.DeleteManufacturer("ZL"); }
public void UpdateManufacturerTest() { ProductManager target = new ProductManager(); // 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 manufacturerName = "Test"; // TODO: Initialize to an appropriate value string address = "TestAddress"; // TODO: Initialize to an appropriate value string country = "Singapore"; // TODO: Initialize to an appropriate value string contact = "+6594326098"; // TODO: Initialize to an appropriate value DBController.DeleteManufacturer(manufacturerName); target.AddManufacturer(manufacturerName, address, country, contact); target.UpdateManufacturer("Test", "TestAddress", "China", "+6594326098"); DataTable targetResult = DBController.FetchManufacturer(); DataRow targetRow = targetResult.Rows[targetResult.Rows.Count - 1]; Assert.AreEqual("Test", targetRow["ManufacturerName"]); Assert.AreEqual("TestAddress", targetRow["Address"]); Assert.AreEqual("China", targetRow["Country"]); Assert.AreEqual("+6594326098", targetRow["Contact"]); DBController.DeleteManufacturer(manufacturerName); }
public void DeleteManufacturerTest() { ProductManager target = new ProductManager(); // 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.FetchManufacturer(); //featch original shop table string manufacturerName = "Test"; // TODO: Initialize to an appropriate value string address = "1234"; // TODO: Initialize to an appropriate value string country = "Apple"; // TODO: Initialize to an appropriate value string contact = "Food"; // TODO: Initialize to an appropriate value DBController.DeleteManufacturer("Test"); target.AddManufacturer(manufacturerName, address, country, contact); target.DeleteManufacturer("Test"); DataTable targetResult = DBController.FetchManufacturer(); Assert.AreEqual(expectedResult.Rows.Count, targetResult.Rows.Count); }