示例#1
0
        public void DeleteMethodOK()
        {
            //create an instance of the class we want to create
            clsFoodCollection AllFood = new clsFoodCollection();
            //create the item of the test data
            clsFood TestItem = new clsFood();
            //var to store the primary key
            Int32 PrimaryKey = 0;

            //set its properties
            TestItem.FoodID    = "1";
            TestItem.FoodName  = "Steak";
            TestItem.FoodPrice = "£20";
            TestItem.Quantity  = "2";
            //set ThisAddress to the test data
            AllFood.ThisFood = TestItem;
            TestItem.FoodID  = PrimaryKey;
            //find the record
            AllFood.ThisFood.Find(PrimaryKey);
            //delete the record
            AllFood.Delete();
            //now find the record
            Boolean Found = AllFood.ThisFood.Find(PrimaryKey);

            //test to see that the record was not found
            Assert.IsFalse(Found);
        }
示例#2
0
        public void AddMethodOK()
        {
            //create an instance of the class we want to create
            clsFoodCollection AllFood = new clsFoodCollection();
            //create the item of the test data
            clsFood TestItem = new clsFood();
            //var to store the primary key
            Int32 PrimaryKey = 0;

            //set its properties
            TestItem.FoodID    = "1";
            TestItem.FoodName  = "Steak";
            TestItem.FoodPrice = "£20";
            TestItem.Quantity  = "2";
            //set ThisAddress to the test data
            AllFood.ThisFood = TestItem;
            //add the record
            PrimaryKey = AllFood.Add();
            //set the primary key of the test data
            TestItem.FoodID = PrimaryKey;
            //find the record
            AllFood.ThisFood.Find(PrimaryKey);
            //test to see that the two values are the same
            Assert.AreEqual(AllFood.ThisFood, TestItem);
        }
示例#3
0
        void DisplayFoods()
        {
            clsFoodCollection Foods = new clsFoodCollection();

            listBox1.DataSource    = Foods.FoodList;
            listBox1.DisplayMember = "FoodName";
            listBox1.ValueMember   = "FoodID";
        }
示例#4
0
        public void InstanceOK()

        {
            //create an instance of the class we want to create
            clsFoodCollection AllFood = new clsFoodCollection();

            //test to see that it exists
            Assert.IsNotNull(AllFood);
        }
示例#5
0
        public void ThisFoodPropertyOK()
        {
            //create an instance of the class we want to create
            clsFoodCollection AllFood = new clsFoodCollection();
            //create some test data to assign to the property
            clsFood TestClient = new clsFood();

            //set the properties of the test object
            TestItem.FoodID    = "1";
            TestItem.FoodName  = "Steak";
            TestItem.FoodPrice = "£20";
            TestItem.Quantity  = "2";
            //assign the data to the property
            AllFood.ThisFood = TestFood;
            //test to see that the two values are the same
            Assert.AreEqual(AllFood.ThisFood, TestFood);
        }
示例#6
0
        void Add()
        {
            clsFoodCollection Foods = new clsFoodCollection();

            Foods.ThisFood.FoodID = -1;
            if (Foods.ThisFood.FoodID == -1)
            {
                Foods.ThisFood.FoodName  = textBox1.Text;
                Foods.ThisFood.FoodType  = textBox3.Text;
                Foods.ThisFood.SellPrice = Convert.ToDecimal(textBox2.Text);
                Foods.Add();
            }
            else
            {
                lblError.Text = "There were problems with the data entered.";
            }
        }
示例#7
0
        public void ListAndCountOK()
        {
            //create an instance of the class we want to create
            clsFoodCollection AllFood = new clsFoodCollection();
            //create some test data to assign to the property
            //in this case the data needs to be a list of objects
            List <clsFood> TestList = new List <clsFood>();
            //add an item to the list
            //create the item of the test data
            clsFood TestItem = new clsFood();

            //set its properties
            TestItem.FoodID    = "1";
            TestItem.FoodName  = "Steak";
            TestItem.FoodPrice = "£20";
            TestItem.Quantity  = "2";
            //add the item to the item test list
            TestList.Add(TestItem);
            //assign the data to the property
            AllFood.FoodList = TestList;
            //test to see that the two values are the same
            Assert.AreEqual(AllFood.Count, TestList.Count);
        }