void Update() { //create an instance of the Roomtype clsRoomtypeCollection Roomtype = new clsRoomtypeCollection(); //validate the data on the web form String Error = Roomtype.ThisRoomtype.Valid(txtRoomID.Text, txtRoomFloor.Text, txtRoomType.Text, txtRoomType.Text, txtDateAdded.Text); //if the data is OK then add it to the subject if (Error == "") { //find the record to update Roomtype.ThisRoomtype.Find(RoomtypeID); Roomtype.ThisRoomtype.RoomtypeID = Convert.ToInt32(txtRoomID.Text); Roomtype.ThisRoomtype.RoomFloorNo = Convert.ToInt32(txtRoomFloor.Text); Roomtype.ThisRoomtype.RoomtypeSize = txtRoomSize.Text; Roomtype.ThisRoomtype.Roomtype = txtRoomType.Text; Roomtype.ThisRoomtype.DateTime = Convert.ToDateTime(txtDateAdded.Text); //update the record Roomtype.Update(); //all done so redirect back to the main page Response.Redirect("Default.aspx"); } else { //report an error lblError.Text = "There were problems with the dat entered" + Error; } }
public void ListAndCountOK() { //create an instance of the class we want to create clsRoomtypeCollection AllRooms = new clsRoomtypeCollection(); //create some test data to assign to the property //in this case the data needs to be a list of objects List <clsRoomType> TestList = new List <clsRoomType>(); //add an item to tge list //create the item of test data clsRoomType TestItem = new clsRoomType(); //set its properties TestItem.Active = true; TestItem.RoomtypeID = 81; TestItem.RoomFloorNo = 1; TestItem.RoomtypeSize = "4 Guests"; TestItem.Roomtype = "Standard"; TestItem.DateTime = DateTime.Now.Date; //add the item to the test list TestList.Add(TestItem); //assign the data to the property AllRooms.RoomtypeList = TestList; //test to see that the two values are the same Assert.AreEqual(AllRooms.Count, TestList.Count); }
public void ReportByRoomTypeTestDataFound() { //create an instance of the filtered data clsRoomtypeCollection FilteredRoomtype = new clsRoomtypeCollection(); //var to store outcome Boolean OK = true; //apply a roomtype that doesnt exist FilteredRoomtype.ReportByRoomtype("Standard"); //check that the correct nuber of recrods are found if (FilteredRoomtype.Count == 2) { //checl that the first recrod is ID 1 if (FilteredRoomtype.RoomtypeList[0].RoomtypeID != 81) { OK = false; } //check that the first ID is 2 if (FilteredRoomtype.RoomtypeList[1].RoomtypeID != 82) { OK = false; } else { OK = false; } // test to see that there are no recrods } Assert.IsTrue(OK); }
public void DeleteMethodOK() { //Create an isntance of the class we want to create clsRoomtypeCollection AllRooms = new clsRoomtypeCollection(); //create the item of test data clsRoomType TestItem = new clsRoomType(); //var to store the primary key Int32 PrimaryKey = 0; //set its proeprties TestItem.Active = false; TestItem.RoomtypeID = 81; TestItem.RoomFloorNo = 1; TestItem.RoomtypeSize = "4 guests"; TestItem.Roomtype = "Standard"; TestItem.DateTime = DateTime.Now.Date; //set ThisRoomtype to the test dat AllRooms.ThisRoomtype = TestItem; //add the record PrimaryKey = AllRooms.Add(); //set the primary key of the tst data TestItem.RoomtypeID = PrimaryKey; //find the record AllRooms.ThisRoomtype.Find(PrimaryKey); //delete the record AllRooms.Delete(); //now find the record Boolean Found = AllRooms.ThisRoomtype.Find(PrimaryKey); //test to see that the record was not found Assert.IsFalse(Found); }
public void AddMethodOK() { //create instance of the class we want to create clsRoomtypeCollection AllRooms = new clsRoomtypeCollection(); //createthe item of the test data clsRoomType TestItem = new clsRoomType(); //var to store the primary key Int32 PrimaryKey = 0; //set its properties TestItem.Active = true; TestItem.RoomFloorNo = 1; TestItem.RoomtypeSize = "4 guests"; TestItem.Roomtype = "Standard"; TestItem.DateTime = DateTime.Now.Date; //Set ThisRoom to test the data AllRooms.ThisRoomtype = TestItem; //add the record PrimaryKey = AllRooms.Add(); //set the primary key of the test data TestItem.RoomtypeID = PrimaryKey;//find the record //find the record AllRooms.ThisRoomtype.Find(PrimaryKey); //test to see that the two values are the same Assert.AreEqual(AllRooms.ThisRoomtype, TestItem); }
public void InstanceOK() { //create an instance of the class we want to create clsRoomtypeCollection AllRooms = new clsRoomtypeCollection(); //test to see that it exists Assert.IsNotNull(AllRooms); }
public void ReportByRoomtypeMethodOK() { //Create instance of the class we want to create clsRoomtypeCollection Allrooms = new clsRoomtypeCollection(); //create an instance of te filtred data clsRoomtypeCollection FilteredRooms = new clsRoomtypeCollection(); //apply a blank string (should return all records) FilteredRooms.ReportByRoomtype(""); //test to see that the two value are the same Assert.AreNotEqual(Allrooms.Count, FilteredRooms.Count); }
void DeleteRoomtype() { //function to delete the selected record //create a new instance of the Roomtype clsRoomtypeCollection RoomType = new clsRoomtypeCollection(); //find the record to delete RoomType.ThisRoomtype.Find(RoomtypeID); //Delete the record RoomType.Delete(); }
void DisplayRoomtype() { //Create an instance of the class we want to create clsRoomtypeCollection Roomtype = new clsRoomtypeCollection(); //find the record to update Roomtype.ThisRoomtype.Find(RoomtypeID); //display the data for this record txtRoomID.Text = Roomtype.ThisRoomtype.RoomtypeID.ToString(); txtRoomFloor.Text = Roomtype.ThisRoomtype.RoomFloorNo.ToString(); txtRoomSize.Text = Roomtype.ThisRoomtype.RoomtypeSize; txtRoomType.Text = Roomtype.ThisRoomtype.Roomtype; txtDateAdded.Text = Roomtype.ThisRoomtype.DateTime.ToString(); }
void DisplayRoomtype() { //create an instance of the roomtype collection clsRoomtypeCollection Roomtype = new clsRoomtypeCollection(); //set the data to source the list of roomtypes in the collection lstRoomtype.DataSource = Roomtype.RoomtypeList; //set the name of the primary key lstRoomtype.DataValueField = "RoomtypeID"; //set the data field to display lstRoomtype.DataTextField = "Roomtype"; //bind the data to the list lstRoomtype.DataBind(); }
public void ThisRoomtypePropertyOK() { //create an instance of the class we want to create clsRoomtypeCollection AllRooms = new clsRoomtypeCollection(); //vreate some test dat to assign to the property clsRoomType TestRooms = new clsRoomType(); //set the properties of the test opbject TestRooms.Active = true; TestRooms.RoomtypeID = 81; TestRooms.RoomFloorNo = 1; TestRooms.RoomtypeSize = "4 Guests"; TestRooms.Roomtype = "Standard"; TestRooms.DateTime = DateTime.Now.Date; //assign the data to the property AllRooms.ThisRoomtype = TestRooms; //test to see if the two values are the same Assert.AreEqual(AllRooms.ThisRoomtype, TestRooms); }
public void UpdateMethodOK() { //Create an isntance of the class we want to create clsRoomtypeCollection AllRooms = new clsRoomtypeCollection(); //create the item of test data clsRoomType TestItem = new clsRoomType(); //var to store the primary key Int32 PrimaryKey = 0; //set its proeprties TestItem.Active = false; TestItem.RoomFloorNo = 1; TestItem.RoomtypeSize = "4 guests"; TestItem.Roomtype = "Standard"; TestItem.DateTime = DateTime.Now.Date; //set ThisRoomtype to the test dat AllRooms.ThisRoomtype = TestItem; //add the record PrimaryKey = AllRooms.Add(); //set the primary key of the tst data TestItem.RoomtypeID = PrimaryKey; //modify the test data TestItem.Active = false; TestItem.RoomFloorNo = 1; TestItem.RoomtypeSize = "4 guests"; TestItem.Roomtype = "Standard"; TestItem.DateTime = DateTime.Now.Date; //set the record based on the new test data AllRooms.ThisRoomtype = TestItem; //update the record AllRooms.Update(); //find the record AllRooms.ThisRoomtype.Find(PrimaryKey); //test to see Thisroomtype matches the test data Assert.AreEqual(AllRooms.ThisRoomtype, TestItem); }