public void updateMethodOK() { clsReviewsCollection AllReviews = new clsReviewsCollection(); clsReviews TestItem = new clsReviews(); Int32 PrimaryKey = 0; TestItem.ReviewApproved = true; TestItem.ReviewRating = 4; TestItem.ReviewerName = "Dave"; TestItem.ReviewText = "Good Product"; TestItem.ReviewedProduct = "Spurs Shorts"; TestItem.DateAdded = DateTime.Now.Date; AllReviews.ThisReviews = TestItem; PrimaryKey = AllReviews.Add(); TestItem.ReviewsId = PrimaryKey; //PrimaryKey = AllReviews = TestItem; //AllReviews.ThisReviews.Add(); TestItem.ReviewApproved = false; TestItem.ReviewRating = 2; TestItem.ReviewerName = "Dom"; TestItem.ReviewText = "Ok Product"; TestItem.ReviewedProduct = " Shorts"; TestItem.DateAdded = DateTime.Now.Date; AllReviews.ThisReviews = TestItem; AllReviews.Update(); AllReviews.ThisReviews.Find(PrimaryKey); Assert.AreEqual(AllReviews.ThisReviews, TestItem); }
public void UpdateMethodOK() { //create an instance of the class we want to create clsReviewsCollection AllReviews = new clsReviewsCollection("Fbloggs"); //create an instance of test data clsReviews TestItem = new clsReviews(); //var to store primary key Int32 PK = 0; //set the properties TestItem.Email = "*****@*****.**"; TestItem.Exp = "*****@*****.**"; TestItem.Improveexp = "*****@*****.**"; //set ThisCustomer to validate test data AllReviews.ThisReview = TestItem; //add the record PK = AllReviews.Add(); //set primary key of test data TestItem.ReviewId = PK; //modify the record TestItem.Email = "*****@*****.**"; TestItem.Exp = "*****@*****.**"; TestItem.Improveexp = "*****@*****.**"; //set the record based on the new record AllReviews.ThisReview = TestItem; //update the record AllReviews.Update(); //find the record AllReviews.ThisReview.Find(PK); //test to see that it exists Assert.AreEqual(AllReviews.ThisReview, TestItem); }
public void DeleteMethodOK() { //create an instance of the class we want to create clsReviewsCollection AllReviews = new clsReviewsCollection("Fbloggs"); //create an instance of test data clsReviews TestItem = new clsReviews(); //var to store primary key Int32 PK = 0; //set the properties //TestItem.CustomerID = 3; TestItem.Email = "*****@*****.**"; TestItem.Exp = "*****@*****.**"; TestItem.Improveexp = "*****@*****.**"; //set ThisCustomer to validate test data AllReviews.ThisReview = TestItem; //add the record PK = AllReviews.Add(); //set primary key of test data TestItem.ReviewId = PK; //find the record AllReviews.ThisReview.Find(PK); //delete the record AllReviews.Delete(); //now find the record Boolean Found = AllReviews.ThisReview.Find(PK); //test to see that it exists Assert.IsFalse(Found); }
public void AddMethodOK() { //create an instance of the class we want to create clsReviewsCollection AllReviews = new clsReviewsCollection("Fbloggs"); //create an instance of test data clsReviews TestItem = new clsReviews(); //var to store primary key Int32 PK = 0; //set the properties //TestItem.CustomerID = 3; TestItem.Email = "*****@*****.**"; TestItem.Exp = "*****@*****.**"; TestItem.Improveexp = "*****@*****.**"; //TestItem.UserName = "******"; //set ThisCustomer to validate test data AllReviews.ThisReview = TestItem; //add the record PK = AllReviews.Add(); //set primary key of test data TestItem.ReviewId = PK; //find the record AllReviews.ThisReview.Find(PK); //test to see that it exists Assert.AreEqual(AllReviews.ThisReview, TestItem); }
//function for Adding records void Add() { //create an instance of the booking list clsReviewsCollection Review = new clsReviewsCollection(User.Identity.Name); //validate the data on the web form //string foreName, string surname, string dateOfBirth, string gender, string contactNumber, string eMail, string flatNo, string houseNo, string postCode String Error = Review.ThisReview.Valid(txtEmail.Text, txtExp.Text, txtImproveexp.Text); //if the data is OK then add it to the object if (Error == "") { //find the record to update //Customer.ThisCustomer.Find(Id); //get the data entered by the user Review.ThisReview.Email = Convert.ToString(txtEmail.Text); Review.ThisReview.Exp = Convert.ToString(txtExp.Text); Review.ThisReview.Improveexp = Convert.ToString(txtImproveexp.Text); //CList.ThisCustomer.UserName = User.Identity.Name; //update the record Review.Add(); //all done so redirect back to the main page // Response.Redirect("AdminHomepage.aspx"); page does not exist lblError.Text = "add"; } else { //report an error lblError.Text = "There were problems with the data entered " + Error; } }
void Add() { clsReviewsCollection Reviews = new clsReviewsCollection(); String Error = Reviews.ThisReviews.Valid(rvwTextOK.Text, rvwNameOK.Text, rvwdProdOK.Text, dateAddOK.Text); if (Error == "") { Reviews.ThisReviews.ReviewText = rvwTextOK.Text; Reviews.ThisReviews.ReviewerName = rvwNameOK.Text; Reviews.ThisReviews.ReviewedProduct = rvwdProdOK.Text; Reviews.ThisReviews.DateAdded = Convert.ToDateTime(dateAddOK.Text); Reviews.ThisReviews.ReviewApproved = Convert.ToBoolean(rvwAppOK.Text); Reviews.Add(); Response.Redirect("Default.aspx"); } else { lblError.Text = "There were problems with the data entered" + Error; } }
public void DeleteMethodOK() { clsReviewsCollection AllReviews = new clsReviewsCollection(); clsReviews TestItem = new clsReviews(); Int32 PrimaryKey = 0; TestItem.ReviewsId = 1; TestItem.ReviewApproved = true; TestItem.ReviewRating = 4; TestItem.ReviewerName = "Dave"; TestItem.ReviewText = "Good Product"; TestItem.ReviewedProduct = "Spurs Shorts"; TestItem.DateAdded = DateTime.Now.Date; AllReviews.ThisReviews = TestItem; PrimaryKey = AllReviews.Add(); TestItem.ReviewsId = PrimaryKey; Boolean Found = AllReviews.ThisReviews.Find(PrimaryKey); AllReviews.Delete(); // Assert.IsFalse(Found); }
/* protected void btnSubmit_Click(object sender, EventArgs e) * { * * if (ReviewsId == -1) * { * Add(); * } * else * { * Update(); * } * }*/ protected void btnSubmit_Click(object sender, EventArgs e) { /* Error = AnReviews.Valid(ReviewedProduct, ReviewText, * DateAdded, ReviewerName); * * * if (Error == "") * { * AnReviews.ReviewsId = ReviewsId; * AnReviews.ReviewerName = ReviewerName; * AnReviews.ReviewText = ReviewText; * AnReviews.ReviewedProduct = ReviewedProduct; * AnReviews.DateAdded = Convert.ToDateTime(DateAdded); * AnReviews.ReviewApproved = chkReviewApproved.Checked; * AnReviews.ReviewRating = ReviewRating.ToString(); * * clsReviewsCollection ReviewsList new clsReviewsCollection(); * * if (ReviewsId == -1) * { * ReviewsList.ThisReviews = AnReviews; * ReviewsList.Add(); * } * * else * { * ReviewsList.ThisReviews.Find(ReviewsId); * ReviewsList.ThisReviews = AnReviews; * ReviewsList.Update(); * * } * Response.Redirect("ReviewsList.aspx"); * * } * else * { * lblError.Text = Error; * }*/ clsReviews Reviews = new clsReviews(); string ReviewRating = rvwRatOK.Text; string ReviewText = rvwTextOK.Text; string ReviewerName = rvwNameOK.Text; string ReviewedProduct = rvwdProdOK.Text; string DateAdded = dateAddOK.Text; string ReviewApproved = rvwAppOK.Text; string Error = ""; Error = AnReviews.Valid(ReviewText, ReviewerName, DateAdded, ReviewedProduct) if (Error == "") { AnReviews.ReviewText = ReviewText; AnReviews.ReviewerName = ReviewerName; AnReviews.ReviewedProduct = ReviewedProduct; AnReviews.DateAdded = Convert.ToDateTime(DateAdded); AnReviews.ReviewApproved = ReviewApproved; AnReviews.ReviewRating = ReviewRating.ToString(); clsReviewsCollection ReviewsList = new clsReviewsCollection(); ReviewsList.ThisReviews = AnReviews; ReviewsList.Add(); Response.Redirect("ReviewsList.aspx"); } else { lblError.Text = Error; } }