Exemplo n.º 1
0
 private void plusProduct_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         int c = Convert.ToInt32(prodCount.Text);
         if (productShopGrid.SelectedItems[0] is Product product && comboShop.SelectedItem is Shop shop)
         {
             addShopItem.AddShpItem(product.Id, shop.Id, c);
             productItemsGrid.ItemsSource = showShopItem.Show(shop);
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Введено некоректное число", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Exemplo n.º 2
0
        public void AddShopItemTest_input_productId_shopId_count_output_true()
        {
            // Arrange
            int productId = 1;
            int shopId    = 2;
            int count     = 5;
            var shopItems = new AddShopItem();
            var repo      = new Mock <ShopItemRepository>();

            repo.Setup(arg => arg.Create(It.IsAny <ShopItem>()));
            repo.Setup(arg => arg.Save());
            shopItems.db = repo.Object;

            // Act
            var result = shopItems.AddShpItem(productId, shopId, count);

            // Assert
            Assert.IsTrue(result);
            repo.Verify(arg => arg.Create(It.IsAny <ShopItem>()), Times.Once());
            repo.Verify(arg => arg.Save(), Times.Once());
        }