public void BookServiceSearchBoundaryTest() //BookService边界测试 { BookService service = BookService.getInstance(); BookListItem book = new BookListItem(); //边界测试需要的数据 List <BookListItem> list; list = service.searchByISBN(book.ISBN, ""); Assert.IsTrue(list == null); //边界测试2,查询,username为空 }
public void BookServiceUpdateFuncTest() //BookService功能测试 { BookService service = BookService.getInstance(); List <BookListItem> list; list = service.searchByISBN("10010", "TestUser"); //正常测试需要的数据 BookListItem book2 = list[0]; book2.Author = "TestAuthorx"; bool ret5 = service.update(book2); //正常测试3,更新 Assert.IsTrue(ret5 == true); }
private void SearchItemClick(object sender, RoutedEventArgs e) { CustomMessageBox box = new CustomMessageBox(); box.Title = "添加到..."; RadioButton rb1 = new RadioButton(); rb1.Content = "想读的书"; RadioButton rb2 = new RadioButton(); rb2.Content = "在读的书"; RadioButton rb3 = new RadioButton(); rb3.Content = "读完的书"; StackPanel rbl = new StackPanel(); rbl.Children.Add(rb1); rbl.Children.Add(rb2); rbl.Children.Add(rb3); box.Content = rbl; box.LeftButtonContent = "确定"; box.RightButtonContent = "取消"; box.Show(); box.Dismissed += (s1, e1) => { Button tb = (Button)sender; BookListItem book = tb.DataContext as BookListItem; book.UserId = phoneAppServeice.State["username"].ToString(); book.Rating = 3; switch (e1.Result) { case CustomMessageBoxResult.LeftButton: if ((bool)rb1.IsChecked) { Debug.WriteLine("[DEBUG]A Wish Book Added."); book.Status = BookStatus.WISH; } if ((bool)rb2.IsChecked) { Debug.WriteLine("[DEBUG]A Reading Book Added."); book.Status = BookStatus.READING; } if ((bool)rb3.IsChecked) { Debug.WriteLine("[DEBUG]A Finish Book Added."); book.HaveReadPage = book.PageNo; book.Status = BookStatus.FINISHED; } List <BookListItem> items = bookService.searchByISBN(book.ISBN, phoneAppServeice.State["username"].ToString()); if (items.Count == 0) { bookService.insert(book); //InsertBookListItem(book); //RefreshWishBookList(); //新增 RefreshReadingPlanItems(); RefreshBookList(); //RefreshFinishBookList(); } else { MessageBox.Show("你已经添加过这本书,无需再次添加!"); return; } MessageBox.Show("添加完毕!"); break; case CustomMessageBoxResult.RightButton: break; case CustomMessageBoxResult.None: break; default: break; } }; }