public void GetQuantityByIdShouldReturnOk() { //Calling GetQuantity By Id Function. var OkResult = controller.GetQuantity(15); //Asserting Values. Assert.IsType <OkObjectResult>(OkResult); }
public void EditQuantityMinus_CorrectData_TrueReturned() { //Arrange int book_id = 5; List <quantity> quantityList = new List <quantity>(); string expectedName = ""; //Act int oldQuantity = dbHelper.context.quantity.Where(t => t.book_id == book_id).FirstOrDefault().library_quantity; quantityList = quantityController.GetQuantity(book_id); if (quantityController.ChangeQuantityMinus(book_id, quantityList)) { dbHelper = new DbHelper(); int newQuantity = dbHelper.context.quantity.Where(t => t.book_id == book_id).FirstOrDefault().library_quantity; //Assert Assert.AreEqual(oldQuantity - 1, newQuantity); } }
/// <summary> /// Событие при клике на кнопку "Удалить" /// </summary> private void DeleteTradingInfoBtn_Click(object sender, RoutedEventArgs e) { var secondSelectedCellContent = new DataGridCellInfo(TradingDataGrid.SelectedItem, TradingDataGrid.Columns[1]); if (TradingDataGrid.SelectedItem == null) { MessageBox.Show("Вы не выбрали ни одной выдачи"); } else { MessageBoxResult result = MessageBox.Show("Вы уверены, что хотите удалить выбранную выдачу?", "Удаление выдачи", MessageBoxButton.YesNo); if (result == MessageBoxResult.Yes) { List <quantity> booksQuantity = new List <quantity>(); TextBlock secondSelectedCell = secondSelectedCellContent.Column.GetCellContent(secondSelectedCellContent.Item) as TextBlock; var item = TradingDataGrid.SelectedItem as trading; int tradingId = Convert.ToInt32(item.trading_id); var lastSelectedCellContent = new DataGridCellInfo(TradingDataGrid.SelectedItem, TradingDataGrid.Columns[5]); TextBlock selectedLogin = lastSelectedCellContent.Column.GetCellContent(lastSelectedCellContent.Item) as TextBlock; if (booksController.RemoveIdTradingFromBook(Convert.ToInt32(secondSelectedCell.Text))) { if (clientsController.RemoveIdTradingFromClient(selectedLogin.Text)) { booksQuantity = quantityController.GetQuantity(Convert.ToInt32(secondSelectedCell.Text)); string ticket = tradingController.GetNeededTicket(tradingId); if (formularController.AddBookReturnDate(DateTime.Now, ticket)) { if (tradingController.RemoveTrading(tradingId)) { if (quantityController.ChangeQuantityPlus(Convert.ToInt32(secondSelectedCell.Text), booksQuantity)) { TradingDataGrid.ItemsSource = tradingController.GetTradingInfo(); BookDataGrid.ItemsSource = booksController.BooksInfoOutput(); TradingClientsGrid.ItemsSource = clientsController.GetClientsWithTrading(); WaitingBooksDataGrid.ItemsSource = waitingController.GetWaitingInfo(); MessageBox.Show("Данные успешно удалены."); } else { MessageBox.Show("Ошибка базы данных, попробуйте позже."); } } else { MessageBox.Show("Ошибка базы данных, попробуйте позже."); } } else { MessageBox.Show("Ошибка базы данных, попробуйте позже."); } } else { MessageBox.Show("Ошибка базы данных, попробуйте позже."); } } else { MessageBox.Show("Ошибка базы данных, попробуйте позже."); } } else { this.NavigationService.Navigate(new MenuLibrarianPage()); } } }