private void reviewButton_Click(object sender, RoutedEventArgs e) { if (this.orderListView.SelectedItem != null) { var dlg = new ReviewItem(); reviewItem = new DALReviewItem(); var selectedOrderItem = this.orderListView.SelectedItem as OrderItem; var isbn = selectedOrderItem.BookID; var title = selectedOrderItem.BookTitle; dlg.isbnTextBox.Text = isbn; dlg.titleTextBox.Text = title; dlg.Owner = this; dlg.ShowDialog(); if (dlg.DialogResult == true) { if (reviewItem.Review(isbn, int.Parse(dlg.orderNoTextBox.Text), int.Parse(dlg.ratingsbutton.Text), dlg.commentsTextBox.Text)) { MessageBox.Show("Your Review Has been submitted."); } else { MessageBox.Show("Your Review Could not be added"); } } } else { MessageBox.Show("Please add a book to review it."); } }
private void addReviewButton_Click(object sender, RoutedEventArgs e) { var dlg = new ReviewItem(Isbn); DALReviewItem reviewItem = new DALReviewItem(); dlg.isbnTextBox.Text = Isbn; dlg.titleTextBox.Text = Title; //dlg.Owner = this; DBQueries dbQ = new DBQueries(); DataSet ds = new DataSet(); String s1 = "select t1.OrderID, t1.UserID from Orders " + "t1 INNER JOIN OrderItem t2 ON t1.OrderID = t2.OrderID Where t2.ISBN = '" + Isbn + "' And t1.UserID = '" + UserID + "'"; // ds = dbQ.SELECT_FROM_TABLE("SELECT * FROM BookData WHERE Title = '" + // dataGridView1.SelectedCells[0].Value.ToString() + "'"); ds = dbQ.SELECT_FROM_TABLE(s1); if (ds.Tables[0].Rows.Count > 0) { var orderID = ds.Tables[0].Rows[0]["OrderID"].ToString(); //MessageBox.Show("fetched orderID is" + orderID); //var title = ds.Tables[0].Rows[0]["Title"].ToString(); dlg.orderNoTextBox.Text = orderID; dlg.ShowDialog(); if (dlg.DialogResult == true) { if (reviewItem.Review(Isbn, int.Parse(orderID), int.Parse(dlg.ratingsbutton.Text), dlg.commentsTextBox.Text)) { MessageBox.Show("Your Review Has been submitted."); } else { MessageBox.Show("Your Review could not be added, if you have already reviewed a book you cannot leave another review"); } } } else { MessageBox.Show("You need to purchase a book to be able to review it."); } }
public void TestMethodAddReview3() //checks if OrderID is valid (cannot be negative) { DALReviewItem revItem = new DALReviewItem(); string bookISBN = "0321146530"; int orderID = -1; //enter invalid orderID (negative) int rating = 1; string comments = "good book"; bool expectedReturnWithBook = false; bool actualReturnWithBook = revItem.Review(bookISBN, orderID, rating, comments); Assert.AreEqual(expectedReturnWithBook, actualReturnWithBook); }
public void TestMethodAddReview() //checks if bookISBN is NULL (it cannot be null) { DALReviewItem revItem = new DALReviewItem(); string bookISBN = null; //"1617290890"; int orderID = 4; int rating = 1; string comments = "good book"; bool expectedReturnWithBook = false; bool actualReturnWithBook = revItem.Review(bookISBN, orderID, rating, comments); Assert.AreEqual(expectedReturnWithBook, actualReturnWithBook); }
public void TestMethodAddReview1() //checks if book actually exists in the library before adding a review to it { DALReviewItem revItem = new DALReviewItem(); string bookISBN = "121212121212"; int orderID = 4; int rating = 1; string comments = "Awesome book!"; bool expectedReturnWithBook = false;// as book does not exist in the database bool actualReturnWithBook = revItem.Review(bookISBN, orderID, rating, comments); Assert.AreEqual(expectedReturnWithBook, actualReturnWithBook); }
public void TestMethodAddReview2() //This Test case will pass, as all the conditions are met { DALReviewItem revItem = new DALReviewItem(); string bookISBN = "0321146530"; int orderID = 29; int rating = 5; string comments = "Awesome book!"; bool expectedReturnWithBook = true; bool expectedDelete = true; bool actualReturnWithBook = revItem.Review(bookISBN, orderID, rating, comments); DBQueries delete = new DBQueries(); bool actualdelete = delete.DELETE_FROM_TABLE("delete from UserReviews where OrderID = '29'"); //delete from table after testing Assert.AreEqual(expectedReturnWithBook, actualReturnWithBook); Assert.AreEqual(expectedDelete, actualdelete); }