public void ChceckViewBackAdd()
        {
            var context    = new FakePizzaSharingContext();
            var controller = new PizzaController(context);
            var result     = controller.Add() as ViewResult;

            Assert.IsTrue(result.ViewBag.Napis == "Dodawanie nowej Pizzy");
        }
        public void ChceckViewNameAdd()
        {
            var context    = new FakePizzaSharingContext();
            var controller = new PizzaController(context);
            var result     = controller.Add() as ViewResult;

            Assert.AreEqual("Add", result.ViewName);
        }
        public void EditViewException()
        {
            var context = new FakePizzaSharingContext();

            context.Dodatki = new[]
            {
                new Dodatek {
                    Id = 1, Name = "Cebula"
                },
            }.AsQueryable();

            var controller = new DodatekController(context);
            var result     = controller.Edit(25);

            Assert.AreEqual(typeof(Exception), result.GetType());
        }
        public void TestDeleteView()
        {
            var context = new FakePizzaSharingContext();

            context.Pizzas = new[] {
                new Pizza {
                    Id = 1, Name = "pizza1", Price = 19.99m, DodatekId = 1
                },
                new Pizza {
                    Id = 2, Name = "pizza2", Price = 10, DodatekId = 2
                },
                new Pizza {
                    Id = 3, Name = "pizza3", Price = 15, DodatekId = 2
                }
            }.AsQueryable();
            var controller = new PizzaController(context);
            var result     = controller.Delete(2) as ViewResult;
            var modelPizza = (Pizza)result.Model;

            Assert.AreEqual(10, modelPizza.Price);
        }
        public void TestDisplayPizzasWithoutPrice()
        {
            var context = new FakePizzaSharingContext();

            context.Pizzas = new[] {
                new Pizza {
                    Id = 1, Name = "pizza1", Price = 19.99m, DodatekId = 1
                },
                new Pizza {
                    Id = 2, Name = "pizza2", Price = 0, DodatekId = 2
                },
                new Pizza {
                    Id = 3, Name = "pizza3", DodatekId = 2
                }
            }.AsQueryable();
            var controller = new PizzaController(context);
            var result     = controller.DisplayPriceless() as ViewResult;
            var modelPizza = (IEnumerable <Pizza>)result.Model;

            Assert.AreEqual(2, modelPizza.Count());
        }