private void DeleteButton_Click(object sender, RoutedEventArgs e)
        {
            Ingredient a = new Ingredient();

            a.IngredientID     = Int32.Parse(idText.Text);
            a.IngredientName   = NameText.Text;
            a.IngredientStock  = Int32.Parse(QuantityText.Text);
            a.IngredientStatus = "Active";
            IngredientController.Delete(a);
            RefreshTable();
        }
        public void Delete_InvalidID_ReturnsNotFoundResult()
        {
            // Arrange
            IDataRepository <Ingredient> mockRepository = Substitute.For <IDataRepository <Ingredient> >();
            IngredientController         ingredientCont = new IngredientController(mockRepository);
            // Act
            var notFoundResult = ingredientCont.Delete(68);

            // Assert
            Assert.IsType <Microsoft.AspNetCore.Mvc.NotFoundObjectResult>(notFoundResult);
        }
Beispiel #3
0
        public static void Show()
        {
            IngredientsDataAcess ingredient = new IngredientsDataAcess();

            Console.Write("Ingredient ID:\n");
            int id = Int32.Parse(Console.ReadLine());

            IngredientController controller = new IngredientController();

            controller.Delete(id);

            Console.WriteLine("\nIngredient deleted!\n");
            Console.ReadKey();
            ClearHelper.Clear();
        }
        public void Delete_ShouldWork()
        {
            // Arrange
            DbContextOptions <RepositoryContext> options = new MockDBHandler().IngredientWithThreeMember().build();

            using (var context = new RepositoryContext(options))
            {
                IDataRepository <Ingredient> mockRepository = new IngredientManager(context);
                IngredientController         ingredientCont = new IngredientController(mockRepository);
                FilterModel fm = new FilterModel();
                //Act
                var putResult = ingredientCont.Delete(2) as OkObjectResult;
                var okResult  = ingredientCont.Get(fm);
                var retObj    = Assert.IsType <ActionResult <PagedCollectionResponse <Ingredient> > >(okResult);
                // Assert
                Assert.Equal(2, retObj.Value.Items.ToList().Count);

                Assert.Equal("Ing1", retObj.Value.Items.ToList()[0].Name);
                Assert.Equal("Ing3", retObj.Value.Items.ToList()[1].Name);
            }
        }