public void AddMethodOK() { clsVendorCollection AllVendors = new clsVendorCollection(); clsVendors TestItem = new clsVendors(); Int32 PrimaryKey = 0; TestItem.OpenToBookings = true; TestItem.VendorNo = 1; TestItem.VendorName = "Pizza place"; TestItem.HouseNo = "12a"; TestItem.Street = "street name"; TestItem.City = "city name"; TestItem.Country = "Country name"; TestItem.PostCode = "PO5 7CO"; TestItem.DateAdded = DateTime.Now.Date; TestItem.VendorType = "Food"; TestItem.Summary = "The best pizza place."; //set ThisVendor to the test data AllVendors.ThisVendor = TestItem; PrimaryKey = AllVendors.Add(); TestItem.VendorNo = PrimaryKey; //find record AllVendors.ThisVendor.Find(PrimaryKey); Assert.AreEqual(AllVendors.ThisVendor, TestItem); }
public void ReportByCountryTestDataFound() { clsVendorCollection FilteredVendors = new clsVendorCollection(); Boolean OK = true; FilteredVendors.ReportByCountry("Italy"); //chack that the correst number of records are found if (FilteredVendors.VendorList.Count == 4) { //check that the first record ID 7 if (FilteredVendors.VendorList[0].VendorNo != 7) { OK = false; } //check that the first record ID 10 if (FilteredVendors.VendorList[1].VendorNo != 10) { OK = false; } //check that the first record ID 12 if (FilteredVendors.VendorList[2].VendorNo != 12) { OK = false; } //check that the first record ID 32 if (FilteredVendors.VendorList[3].VendorNo != 32) { OK = false; } } }
public void VendorListOK() { //create instance of class clsVendorCollection AllVendors = new clsVendorCollection(); //create some test data to assign to the property List <clsVendors> TestList = new List <clsVendors>(); //create and add item to list clsVendors TestItem = new clsVendors(); //set its properties TestItem.OpenToBookings = true; TestItem.VendorNo = 1; TestItem.VendorName = "Pizza place"; TestItem.HouseNo = "12a"; TestItem.Street = "street name"; TestItem.City = "city name"; TestItem.Country = "Country name"; TestItem.PostCode = "PO5 7CO"; TestItem.DateAdded = DateTime.Now.Date; TestItem.VendorType = "Food"; TestItem.Summary = "The best pizza place."; //add the item to the test list TestList.Add(TestItem); //assign the data to the property AllVendors.VendorList = TestList; //test to see that the two values are the same Assert.AreEqual(AllVendors.VendorList, TestList); }
public void ReportByCountryNoneFound() { clsVendorCollection FilteredVendors = new clsVendorCollection(); FilteredVendors.ReportByCountry("xxxxxx"); Assert.AreEqual(0, FilteredVendors.Count); }
protected void btnYes_Click(object sender, EventArgs e) { clsVendorCollection VendorBook = new clsVendorCollection(); VendorBook.ThisVendor.Find(VendorNo); VendorBook.Delete(); Response.Redirect("VendorList.aspx"); }
public void ReportByCountryMethodOK() { clsVendorCollection AllVendors = new clsVendorCollection(); clsVendorCollection FilteredVendors = new clsVendorCollection(); FilteredVendors.ReportByCountry(""); Assert.AreEqual(AllVendors.Count, FilteredVendors.Count); }
public void InstanceOK() { //create an instance of the class we want to create clsVendorCollection AllVendors = new clsVendorCollection(); //test to see that it exists Assert.IsNotNull(AllVendors); }
protected void btnSubmit_Click(object sender, EventArgs e) { //create new instance of clsVendors clsVendors AVendor = new clsVendors(); //captures information string VendorName = txtVendorName.Text; string HouseNo = txtHouseNo.Text; string Street = txtStreet.Text; string City = txtCity.Text; string PostCode = txtPostcode.Text; string Country = txtCountry.Text; string VendorType = txtVendorType.Text; string DateAdded = txtDateAdded.Text; string Summary = txtSummary.Text; bool OpenToBookings = chkOpenToBookings.Checked; //variable to store any error messages string Error = ""; //validate data Error = AVendor.Valid(HouseNo, Street, City, PostCode, Country, DateAdded, VendorName, VendorType, Summary); if (Error == "") { //capture the vendor no AVendor.VendorNo = VendorNo; //captures information AVendor.VendorName = VendorName; AVendor.HouseNo = HouseNo; AVendor.Street = Street; AVendor.City = City; AVendor.PostCode = PostCode; AVendor.Country = Country; AVendor.DateAdded = Convert.ToDateTime(DateAdded); AVendor.VendorType = VendorType; AVendor.Summary = Summary; AVendor.OpenToBookings = chkOpenToBookings.Checked; clsVendorCollection VendorList = new clsVendorCollection(); //if it is a new record if (VendorNo == -1) { VendorList.ThisVendor = AVendor; VendorList.Add(); } else //it is an update { VendorList.ThisVendor.Find(VendorNo); VendorList.ThisVendor = AVendor; VendorList.Update(); } Response.Redirect("VendorList.aspx"); } else { //display error message lblError.Text = Error; } }
protected void btnApply_Click(object sender, EventArgs e) { clsVendorCollection Vendors = new clsVendorCollection(); Vendors.ReportByCountry(txtFilter.Text); lstVendors.DataSource = Vendors.VendorList; //set Name of primary key lstVendors.DataValueField = "VendorNo"; //set Name of the field to display lstVendors.DataTextField = "Country"; //bind data to the list lstVendors.DataBind(); }
void DisplayVendor() { clsVendorCollection VendorBook = new clsVendorCollection(); VendorBook.ThisVendor.Find(VendorNo); //display data for this record txtVendorNo.Text = VendorBook.ThisVendor.VendorNo.ToString(); txtVendorName.Text = VendorBook.ThisVendor.VendorName; txtHouseNo.Text = VendorBook.ThisVendor.HouseNo; txtStreet.Text = VendorBook.ThisVendor.Street; txtCity.Text = VendorBook.ThisVendor.City; txtCountry.Text = VendorBook.ThisVendor.Country; txtPostcode.Text = VendorBook.ThisVendor.PostCode; txtVendorType.Text = VendorBook.ThisVendor.VendorType; txtSummary.Text = VendorBook.ThisVendor.Summary; txtDateAdded.Text = VendorBook.ThisVendor.DateAdded.ToString(); chkOpenToBookings.Checked = VendorBook.ThisVendor.OpenToBookings; }
public void ThisVendorPropertyOk() { clsVendorCollection AllVendors = new clsVendorCollection(); clsVendors TestVendor = new clsVendors(); //set properties pf the test object TestVendor.OpenToBookings = true; TestVendor.VendorNo = 1; TestVendor.VendorName = "Pizza place"; TestVendor.HouseNo = "12a"; TestVendor.Street = "street name"; TestVendor.City = "city name"; TestVendor.Country = "Country name"; TestVendor.PostCode = "PO5 7CO"; TestVendor.DateAdded = DateTime.Now.Date; TestVendor.VendorType = "Food"; TestVendor.Summary = "The best pizza place."; //assign the data to the property AllVendors.ThisVendor = TestVendor; Assert.AreEqual(AllVendors.ThisVendor, TestVendor); }
public void ListAndCountOK() { //create instance of class clsVendorCollection AllVendors = new clsVendorCollection(); List <clsVendors> TestList = new List <clsVendors>(); clsVendors TestItem = new clsVendors(); TestItem.OpenToBookings = true; TestItem.VendorNo = 1; TestItem.VendorName = "Pizza place"; TestItem.HouseNo = "12a"; TestItem.Street = "street name"; TestItem.City = "city name"; TestItem.Country = "Country name"; TestItem.PostCode = "PO5 7CO"; TestItem.DateAdded = DateTime.Now.Date; TestItem.VendorType = "Food"; TestItem.Summary = "The best pizza place."; TestList.Add(TestItem); AllVendors.VendorList = TestList; Assert.AreEqual(AllVendors.Count, TestList.Count); }