void Update() { //create an instance of the menu book clsMenuCollection MenuBook = new clsMenuCollection(); //validate the data on the web form String Error = MenuBook.ThisItem.Valid(txtName.Text, txtDescription.Text, Convert.ToInt32(txtRecipe.Text), Convert.ToDouble(txtPrice.Text)); //if the data is OK then add it to the object if (Error == "") { //find the record to update MenuBook.ThisItem.Find(MenuID); //get the data entered by the user MenuBook.ThisItem.Name = txtName.Text; MenuBook.ThisItem.Description = txtDescription.Text; MenuBook.ThisItem.RecipeID = Convert.ToInt32(txtRecipe.Text); MenuBook.ThisItem.Price = Convert.ToDouble(txtPrice.Text); //update the record MenuBook.Update(); //all done so redirect back to the main page Response.Redirect("MenuList.aspx"); } else { //report an error lblError.Text = "There were problems with the data entered " + Error; } }
//[TestMethod] public void UpdateMethodOK() { //create an instance of the class we want to create clsMenuCollection AllMenu = new clsMenuCollection(); //create the item of test data clsMenu TestItem = new clsMenu(); //var to store the primary key Int32 PrimaryKey = 0; //set the properties TestItem.Name = "Chees"; TestItem.Description = "Super Cheesy"; TestItem.RecipeID = 1; TestItem.Price = 5.0; //set ThisMenu to test data AllMenu.ThisItem = TestItem; //add the record PrimaryKey = AllMenu.Add(); //set the primary key of the test data TestItem.MenuItemID = PrimaryKey; //modify the data TestItem.Name = "Spicy"; TestItem.Description = "Mouth melting goodness"; TestItem.RecipeID = 5; TestItem.Price = 7.5; //set the record based on the new test data AllMenu.ThisItem = TestItem; //update the record AllMenu.Update(); //find the record AllMenu.ThisItem.Find(PrimaryKey); //test to see this menu matches Assert.AreEqual(AllMenu.ThisItem, TestItem); }
public void AddMethodOK() { //create an instance of the class we want to create clsMenuCollection AllMenu = new clsMenuCollection(); //create the item of test data clsMenu TestItem = new clsMenu(); //var to store the primary key Int32 PrimaryKey = 0; //set the properties TestItem.Name = "Cheesy"; TestItem.Description = "Classic cheese delite!"; TestItem.RecipeID = 1; TestItem.Price = 5.0; //set ThisMenu to test data AllMenu.ThisItem = TestItem; //add the record PrimaryKey = AllMenu.Add(); //set the primary key of the test data TestItem.MenuItemID = PrimaryKey; //find the record AllMenu.ThisItem.Find(PrimaryKey); //test to see that the two values are the same Assert.AreEqual(AllMenu.ThisItem, TestItem); }
public void DeleteMethodOK() { //create an instance of the class we want to create clsMenuCollection AllMenu = new clsMenuCollection(); //create the item of test data clsMenu TestItem = new clsMenu(); //var to store the primary key Int32 PrimaryKey = 0; //set the properties TestItem.MenuItemID = 0; TestItem.Name = "Cheesy"; TestItem.Description = "Classic cheese delite!"; TestItem.RecipeID = 1; TestItem.Price = 5.0; //set ThisMenu to test data AllMenu.ThisItem = TestItem; //add the record PrimaryKey = AllMenu.Add(); //set the primary key of the test data TestItem.MenuItemID = PrimaryKey; //find the record AllMenu.ThisItem.Find(PrimaryKey); //delete the record AllMenu.Delete(); //now find the record Boolean Found = AllMenu.ThisItem.Find(PrimaryKey); //test to see that the record was not found Assert.IsFalse(Found); }
public void InstanceOK() { //create an instance of the class we want to create clsMenuCollection AllMenu = new clsMenuCollection(); //test to see that it exists Assert.IsNotNull(AllMenu); }
void DeleteMenuItem() { //function to delete the selected record //create a new instance of the MenuBook clsMenuCollection MenuBook = new clsMenuCollection(); //find the record to delete MenuBook.ThisItem.Find(MenuID); //delete the record MenuBook.Delete(); }
public void RepostByPizzaNameMethodOK() { //create an instance of the class we want to create clsMenuCollection AllMenu = new clsMenuCollection(); //create an instance of the filtered pizza clsMenuCollection FilteredPizza = new clsMenuCollection(); //apply a blank string (should return all records) FilteredPizza.ReportByPizzaName(""); //test to see that the two values are the same Assert.AreEqual(AllMenu.Count, FilteredPizza.Count); }
void DisplayMenu() { //create an instance of the menu book clsMenuCollection MenuBook = new clsMenuCollection(); //find the record to update MenuBook.ThisItem.Find(MenuID); //display the data for this record txtName.Text = MenuBook.ThisItem.Name; txtDescription.Text = MenuBook.ThisItem.Description; txtRecipe.Text = MenuBook.ThisItem.RecipeID.ToString(); txtPrice.Text = MenuBook.ThisItem.Price.ToString(); }
void DisplayMenu() { //create an instance of the Menu collection clsMenuCollection Menu = new clsMenuCollection(); //set the data source to the list of Menu items in the collection lstMenu.DataSource = Menu.MenuList; //set the name of the primary key lstMenu.DataValueField = "MenuItemID"; //set the data field to display lstMenu.DataTextField = "Name"; //bind the data to the list lstMenu.DataBind(); }
public void ThisMenuItemPropertyOK() { //create an instance of the class we want to create clsMenuCollection AllMenu = new clsMenuCollection(); //create the item of test data clsMenu TestMenu = new clsMenu(); //set its properties TestMenu.MenuItemID = 1; TestMenu.Name = "Classic Cheese"; TestMenu.Description = "SUPER CHEESY GOOD!"; TestMenu.RecipeID = 3; TestMenu.Price = 9.9; //assign the data to the property AllMenu.ThisMenuItem = TestMenu; //test they're the same Assert.AreEqual(AllMenu.ThisMenuItem, TestMenu); }
public void ListAndCountOK() { //create an instance of the class we want to create clsMenuCollection AllMenu = new clsMenuCollection(); //create some test data to assign to the property //in this case the data needs to be a list of objects List <clsMenu> TestList = new List <clsMenu>(); //add an item to the list //create the item of test data clsMenu TestItem = new clsMenu(); //set its properties TestItem.MenuItemID = 1; TestItem.Name = "Classic Cheese"; TestItem.Description = "SUPER CHEESY GOOD!"; TestItem.RecipeID = 3; TestItem.Price = 9.9; //add the item to the test list TestList.Add(TestItem); //assign the data to the property AllMenu.MenuList = TestList; //test to see that the two values are the same Assert.AreEqual(AllMenu.Count, TestList.Count); }