public void BookServiceInsertBoundaryTest() //BookService边界测试 { BookService service = BookService.getInstance(); BookListItem book = new BookListItem(); //边界测试需要的数据 bool ret = service.insert(book); //边界测试1,插入,Book内容为空 Assert.IsTrue(ret == false); }
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; } }; }