Exemplo n.º 1
0
        static void Main(string[] args)
        {
            using (var db = new DataContext())
            {
                // Create and save a new Blog
                Console.Write("Enter a name for a new Blog: ");
                var name = Console.ReadLine();

                var blog = new PizzaMaker {
                    Id = 1, Name = "Name", Surname = "Surname"
                };
                db.PizzaMakers.Add(blog);
                // db.SaveChanges();

                // Display all Blogs from the database
                var query = from b in db.PizzaMakers
                            orderby b.Name
                            select b;

                Console.WriteLine("All blogs in the database:");
                foreach (var item in query)
                {
                    Console.WriteLine(item.Name);
                }

                Console.WriteLine("Press any key to exit...");
                Console.ReadKey();
            }
        }
Exemplo n.º 2
0
        public ActionResult Edit(int id)
        {
            PizzaMaker pizzaMaker = unitOfWork.PizzaMakerRepository.Get(id);

            if (pizzaMaker == null)
            {
                return(HttpNotFound());
            }
            return(View(pizzaMaker));
        }
Exemplo n.º 3
0
 public ActionResult Create(PizzaMaker pizzaMaker)
 {
     if (ModelState.IsValid)
     {
         unitOfWork.PizzaMakerRepository.Create(pizzaMaker);
         unitOfWork.Save();
         return(RedirectToAction("Index", "PizzaMaker"));
     }
     return(View(pizzaMaker));
 }
        static void Main(string[] args)
        {
            var pizzaMaker = new PizzaMaker(new QuatroFormaggiPizzaBuilder(Crust.Thin, Size.Medium));

            pizzaMaker.BuildPizza();
            Console.WriteLine(pizzaMaker.GetPizza().GetRecipe());

            var pizzaMakerPeperoni = new PizzaMaker(new PeperoniPizzaBuilder(Crust.Thick, Size.Medium));

            pizzaMakerPeperoni.BuildPizza();
            Console.WriteLine(pizzaMakerPeperoni.GetPizza().GetRecipe());
        }
Exemplo n.º 5
0
        public List <PizzaPie> OrderPizza(string name, int quantity)
        {
            var count = 1;
            var pies  = new List <PizzaPie>();

            while (count <= quantity)
            {
                pies.Add(PizzaMaker.MakePizza(name));
                count += 1;
            }

            return(pies);
        }
Exemplo n.º 6
0
        public void Main()
        {
            var pizzaMaker   = new PizzaMaker();
            var pizza        = new Pizza();
            var emailService = new EmailService();
            var ovenTimer    = new OvenTimer();

            pizzaMaker.PizzaBaked += ovenTimer.OnPizzaBaked;
            pizzaMaker.PizzaBaked += emailService.OnPizzaBaked;

            pizzaMaker.PizzaBaked += (s, e) => { System.Console.WriteLine("Boxing Pizza"); };
            pizzaMaker.Bake(pizza);
        }
Exemplo n.º 7
0
        public void WhenMakePizzaEndsThenPizzaMakerIsReadyForAnotherPizza()
        {
            // ARRANGE
            var stubIngredientsProvider = MockRepository.GenerateStub <IIngredientsProvider>();
            var stubRawPizzaBUilder     = MockRepository.GenerateStub <IRawPizzaBuilder>();
            var stubOven = MockRepository.GenerateStub <IOven>();

            // ACT
            var sut   = new PizzaMaker(stubIngredientsProvider, stubRawPizzaBUilder, stubOven);
            var pizza = sut.MakePizza();

            // ASSERT
            Assert.IsTrue(sut.ReadyForMakePizza);
        }
Exemplo n.º 8
0
        public void TestBuildingPizza()
        {
            MockPizzaBuilder testBuilder = new MockPizzaBuilder();
            PizzaMaker       pizzaMaker  = new PizzaMaker(testBuilder);

            pizzaMaker.BuildPizza();
            Pizza pizza = pizzaMaker.GetPizza();

            Assert.AreEqual(1, pizza.Id);
            Assert.AreEqual("Test Pizza", pizza.Name);
            Assert.AreEqual(100, pizza.Cost);
            Assert.AreEqual(typeof(Topping), pizza.Toppings.First().GetType());
            Assert.AreEqual(2, pizza.Toppings.Count);
        }
Exemplo n.º 9
0
        public ActionResult Edit(PizzaMaker pizzaMaker)
        {
            if (ModelState.IsValid)
            {
                var toUpdate = unitOfWork.PizzaMakerRepository.Get(pizzaMaker.Id);
                toUpdate.Name    = pizzaMaker.Name;
                toUpdate.Surname = pizzaMaker.Surname;

                unitOfWork.PizzaMakerRepository.Update(toUpdate);
                unitOfWork.Save();
                return(RedirectToAction("Index"));
            }
            return(View(pizzaMaker));
        }
Exemplo n.º 10
0
        public void PizzaCanBeDelivered()
        {
            var pizzaMaker = new PizzaMaker();

            pizzaMaker.AddStep(MakeDough);
            pizzaMaker.AddStep(RollDough);
            pizzaMaker.AddStep(AddToppings);
            pizzaMaker.AddStep(Bake);
            pizzaMaker.AddStep(CheckQuality);
            pizzaMaker.AddStep(Deliver);
            pizzaMaker.Make();

            AssertPizzaIsMade();
        }
Exemplo n.º 11
0
        static void Main(string[] args)
        {
            Random rand = new Random();
            Arr    arr  = new Arr(5);

            arr.insert(1, 2);
            DateTime  time = DateTime.Now;
            Lst <int> l    = new Lst <int>();

            for (int i = 0; i < 5; i++)
            {
                l.insertToStart(i);
                arr.insert(i);
            }
            l.update(4, 55);


            Console.WriteLine("TIme :" + (DateTime.Now - time));
            Queue <int> stak  = new Queue <int>();
            Table       table = new Table();



            Worker       pizzaMaker   = new PizzaMaker("Gleb");
            Worker       disshwasher  = new Dishwasher("OLEG");
            PizzeriaRest pizzeriaRest = new PizzeriaRest();

            pizzeriaRest.AddWorker(pizzaMaker);
            pizzeriaRest.AddWorker(disshwasher);

            var ord1 = new Order();

            ord1.AddPizza(new Pizza("Вкусная", 3, 15));
            ord1.AddPizza(new Pizza("Нажористая", 5, 18));
            pizzeriaRest.pizzaOrders.insertToStart(ord1);
            Order ord2 = new Order();

            ord2.AddPizza(new Pizza("Вкусная", 3, 15));
            ord2.AddPizza(new Pizza("Вкусная", 3, 15));
            ord2.AddPizza(new Pizza("Вкусная", 3, 15));
            ord2.AddPizza(new Pizza("Вкусная", 3, 15));
            pizzeriaRest.pizzaOrders.insertToStart(ord2);
            while (true)
            {
                pizzeriaRest.Work();
                Thread.Sleep(1000);
                Console.Clear();
            }
        }
Exemplo n.º 12
0
        public void IfQualityIsComprised_ThenCustomerIsNotified()
        {
            var pizzaMaker = new PizzaMaker();

            pizzaMaker.AddStep(MakeDough);
            pizzaMaker.AddStep(RollDough);
            pizzaMaker.AddStep(AddToppings);
            pizzaMaker.AddStep(AddCockroach);
            pizzaMaker.AddStep(Bake);
            pizzaMaker.AddStep(CheckQuality);
            pizzaMaker.AddStep(Deliver);
            pizzaMaker.Make();

            Assert.That(_customerNotified, Is.True);
        }
Exemplo n.º 13
0
        public void WeNeverForgetToCookPizzaInTheOven()
        {
            // ARRANGE
            var stubIngredientsProvider = MockRepository.GenerateStub <IIngredientsProvider>();
            var stubRawPizzaBUilder     = MockRepository.GenerateStub <IRawPizzaBuilder>();
            var mockOven = MockRepository.GenerateStub <IOven>();

            mockOven.Stub(oven => oven.CookPizza(Arg <IRawPizza> .Is.Anything));

            // ACT
            var sut   = new PizzaMaker(stubIngredientsProvider, stubRawPizzaBUilder, mockOven);
            var pizza = sut.MakePizza();

            // ASSERT
            mockOven.AssertWasCalled(oven => oven.CookPizza(Arg <IRawPizza> .Is.Anything));
        }
Exemplo n.º 14
0
        public void WhyTheStrictMockIsGenerallyBad()
        {
            //ARRANGE
            var stubIngredientsProvider = MockRepository.GenerateStub <IIngredientsProvider>();
            var stubRawPizzaBuilder     = MockRepository.GenerateStub <IRawPizzaBuilder>();

            var mockOven = MockRepository.GenerateStrictMock <IOven>(); //DISCOURAGED

            mockOven.Expect(oven => oven.Temperature = 300);
            mockOven.Expect(oven => oven.Temperature = 150);
            mockOven.Expect(oven => oven.CookPizza(Arg <IRawPizza> .Is.Anything));

            // ACT
            var sut = new PizzaMaker(stubIngredientsProvider, stubRawPizzaBuilder, mockOven);

            sut.MakePizza();

            // ASSERT
            mockOven.VerifyAllExpectations();
        }
Exemplo n.º 15
0
        public static void Main()
        {
            var maker = new PizzaMaker(new ConsoleRenderer());

            var command = maker.Render.InputFromEnum <Command>(" What to do? ", ConsoleColor.DarkBlue);

            while ((Command)command != Command.Exit)
            {
                switch ((Command)command)
                {
                case Command.Create:
                    var pizzaName = maker.Render.Input("Pizza name");
                    var forWhere  = maker.Render.InputFromEnum <ForType>("Choose for: ");
                    var size      = maker.Render.InputFromEnum <SizeType>("Choose size: ");
                    var pizza     = maker.Create(pizzaName, (ForType)forWhere, (SizeType)size);

                    maker.Render.RenderPizza(pizza);

                    break;

                case Command.Sell:
                    var name = maker.Render.Input("Pizza to sell: ");
                    if (maker.Pizzas.All(p => p.Name != name))
                    {
                        break;
                    }

                    maker.Sell(maker.Pizzas.FirstOrDefault(p => p.Name == name));
                    break;

                default:
                    Environment.Exit(0);
                    break;
                }

                command = maker.Render.InputFromEnum <Command>(" What to do next? ", ConsoleColor.Black);
            }

            Console.ReadKey();
        }
Exemplo n.º 16
0
        public void PizzaMakerSetOvenToTheProperTemperature()
        {
            // ARRANGE
            IIngredientsProvider stubIngredientsProvider = MockRepository.GenerateStub <IIngredientsProvider>();
            IRawPizzaBuilder     stubRawPizzaBUilder     = MockRepository.GenerateStub <IRawPizzaBuilder>();

            // this won't work. We can't verify this call. If you comment out the property settings in the method under test, this test won't fail
            //IOven mockOven = MockRepository.GenerateStub<IOven>();
            //mockOven.Temperature = 300;
            //mockOven.Temperature = 150;

            //this is the proper way to check settings on property
            IOven mockOven = MockRepository.GenerateMock <IOven>();

            mockOven.Expect(oven => oven.Temperature = 300);
            mockOven.Expect(oven => oven.Temperature = 150);

            // ACT
            var sut   = new PizzaMaker(stubIngredientsProvider, stubRawPizzaBUilder, mockOven);
            var pizza = sut.MakePizza();

            // ASSERT
            mockOven.VerifyAllExpectations();
        }
Exemplo n.º 17
0
 public PizzaController(PizzaDbContext context)
 {
     _context    = context;
     _pizzaMaker = new PizzaMaker();
 }
Exemplo n.º 18
0
 public PizzaMakerForm(PizzaMaker pz)
 {
     this.pz = pz;
     InitializeComponent();
     PizzaBox.DataSource = Enum.GetValues(typeof(Pizza));
 }
Exemplo n.º 19
0
 public void ProjectReference()
 {
     var p = PizzaMaker.MakePizza("Pineapple");
 }
Exemplo n.º 20
0
 private void PizzaMaker_OnCook(PizzaMaker maker, Pizza pizza)
 {
     //Console.WriteLine($"Пицца {pizza.Name} готовиться");
     PizzaNakerWork    = $"Пицца {pizza.Name} готовиться";
     PizzaMakerWorkImg = Application.StartupPath + "\\Pictures" + "\\PizzaOn.jpg";
 }