コード例 #1
0
 public string HiredWriter(Bakery bakery)
 {
     if (bakery.listOfBakers.Count < 9)
     {
         return(bakery.listOfBakers.Last().Name + " hired!" + " (" + bakery.listOfBakers.Last().WorkTitle + ")");
     }
     else
     {
         return("You have reached the maximum number of bakers");
     }
 }
コード例 #2
0
        public void Update(string id, Bakery bakery)
        {
            Bakery foundBakery = _bakeries.Find(n => n.Id == id).FirstOrDefault();

            foundBakery.Name    = bakery.Name;
            foundBakery.Address = bakery.Address;
            foundBakery.Email   = bakery.Email;
            foundBakery.Phone   = bakery.Phone;

            _bakeries.ReplaceOne(bakery => bakery.Id == id, foundBakery);
        }
        public void Check_Equals_Bakery_Ans_Null()
        {
            string[] line      = { "Вода", "1кг", "2р", "0Дж", "Мука", "0,2кг", "1р", "200Дж" };
            Bakery   product   = new Bread(line, 1.2, 3, 200, 10);
            Bakery   product_2 = null;

            bool expected = false;
            bool actual   = product.Equals(product_2);

            Assert.AreEqual(expected, actual);
        }
コード例 #4
0
        public void TestIfOrderCompleteCheckerWorks()
        {
            Bakery   bakery   = new Bakery();
            DateTime test     = DateTime.Now;
            Payment  payments = new Payment();
            Order    order    = new Order(test, new Baker(test), new Customer());

            bakery.listOfOrders.Add(order);
            test = test.AddDays(1);
            //passes if string isn't empty
            Assert.AreNotEqual("", bakery.CheckIfOrderIsComplete(test, payments));
        }
コード例 #5
0
        private async Task UpdateImage(Bakery bakery, IFormFile Image)
        {
            if (Image != null)
            {
                using (var stream = new MemoryStream())
                {
                    await Image.CopyToAsync(stream);

                    bakery.Image = stream.ToArray();
                }
            }
        }
コード例 #6
0
        public IActionResult Update(string id, Bakery bakeryIn)
        {
            var bakeryFromDB = _bakeryService.GetById(id);

            if (bakeryFromDB == null)
            {
                return(NotFound());
            }
            _bakeryService.Update(id, bakeryIn);

            return(NoContent());
        }
コード例 #7
0
        public async Task <Bakery> BakeryReg(Bakery bakery, string password)
        {
            byte[] PasswordHash, PasswordSalt;
            CreatePasswordHash(password, out PasswordHash, out PasswordSalt);
            bakery.PasswordHash = PasswordHash;
            bakery.PasswordSalt = PasswordSalt;
            await _context.Bakery.AddAsync(bakery);

            await _context.SaveChangesAsync();

            return(bakery);
        }
コード例 #8
0
        private void Run()
        {
            // runs until store is closed
            while (!Bakery.GetInstance().IsClosed())
            {
                Thread.Sleep(1000);
                Bakery.GetInstance().SellCookieToCustomer(this);
            }

            Console.WriteLine(Name + " went home.");
            Console.ReadKey(); // to keep console open, so you can read input
        }
コード例 #9
0
        public void TestFindProductsByVolume()  // Тестирование метода FindProductsByVolume()
        {
            // Arrange
            List <Ingredient> ingredients = new List <Ingredient>()
            {
                new Ingredient("Вода", 0.2M, 0, 100),
                new Ingredient("Мука", 0.3M, 360, 350),
                new Ingredient("Масло", 1M, 884, 50)  //500  70%
            };
            Production        production   = new Production("Батон", ingredients, 20);
            List <Ingredient> ingredients1 = new List <Ingredient>()
            {
                new Ingredient("Мука", 0.3M, 360, 350),
                new Ingredient("Вода", 0.2M, 0, 100),
                new Ingredient("Дрожжи", 0.5M, 325, 25),
                new Ingredient("Масло", 1M, 884, 50)  //525  66.67%
            };
            Production        production1  = new Production("Хлеб", ingredients1, 15);
            List <Ingredient> ingredients2 = new List <Ingredient>()
            {
                new Ingredient("Мука", 0.3M, 360, 150),
                new Ingredient("Вода", 0.2M, 0, 200),
                new Ingredient("Дрожжи", 0.5M, 325, 50),
                new Ingredient("Масло", 1M, 884, 100)  //500    30%
            };
            Production        production2  = new Production("Хлеб Минский", ingredients2, 25);
            List <Ingredient> ingredients3 = new List <Ingredient>()
            {
                new Ingredient("Мука", 0.3M, 360, 350),
                new Ingredient("Вода", 0.2M, 0, 100),
                new Ingredient("Масло", 1M, 884, 50),
                new Ingredient("Сахар", 0.7M, 325, 125),
                new Ingredient("Сгущенка", 0.2M, 416, 100)  //725  48%
            };
            Production        production3  = new Production("Плюшка со сгущенкой", ingredients3, 15);
            List <Production> testProducts = new List <Production>()
            {
                production, production1, production2, production3
            };
            List <Production> expectedProducts = new List <Production>()
            {
                production, production1
            };
            Bakery actualBakery   = new Bakery(testProducts.ToArray());
            Bakery expectedBakery = new Bakery(expectedProducts.ToArray());

            // Act
            actualBakery.Products = WorkWithArray.FindProductsByVolume(actualBakery, "Мука", 50);

            // Arrange
            Assert.Equal(expectedBakery, actualBakery);
        }
コード例 #10
0
        public void TestFindProductsCountMoreThanNumber() // Тестирование метода FindProductsCountMoreThanNumber()
        {
            // Arrange
            List <Ingredient> ingredients = new List <Ingredient>()
            {
                new Ingredient("Вода", 0.2M, 0, 100),   // 0.2
                new Ingredient("Мука", 0.3M, 360, 350), // 1.05
                new Ingredient("Масло", 1M, 884, 50)    // 0.5   2.1
            };
            Production        production   = new Production("Батон", ingredients, 20);
            List <Ingredient> ingredients1 = new List <Ingredient>()
            {
                new Ingredient("Мука", 0.3M, 360, 350),  // 1.05
                new Ingredient("Вода", 0.2M, 0, 100),    // 0.2
                new Ingredient("Дрожжи", 0.5M, 325, 25), // 0.125
                new Ingredient("Масло", 1M, 884, 50)     // 0.5  2.16
            };
            Production        production1  = new Production("Хлеб", ingredients1, 15);
            List <Ingredient> ingredients2 = new List <Ingredient>()
            {
                new Ingredient("Мука", 0.3M, 360, 150),  // 0.45
                new Ingredient("Вода", 0.2M, 0, 200),    // 0.4
                new Ingredient("Дрожжи", 0.5M, 325, 50), // 0.25
                new Ingredient("Масло", 1M, 884, 100)    // 1  2.63
            };
            Production        production2  = new Production("Хлеб Минский", ingredients2, 25);
            List <Ingredient> ingredients3 = new List <Ingredient>()
            {
                new Ingredient("Мука", 0.3M, 360, 350),    // 1.05
                new Ingredient("Вода", 0.2M, 0, 100),      // 0.2
                new Ingredient("Масло", 1M, 884, 50),      // 1
                new Ingredient("Сахар", 0.7M, 325, 125),   // 0.875
                new Ingredient("Сгущенка", 0.2M, 416, 100) // 0.2  3.88
            };
            Production        production3    = new Production("Плюшка со сгущенкой", ingredients3, 15);
            List <Production> expectProducts = new List <Production>()
            {
                production1, production2, production3
            };
            List <Production> testProducts = new List <Production>()
            {
                production, production1, production2, production3
            };
            Bakery actualBakery   = new Bakery(testProducts.ToArray());
            Bakery expectedBakery = new Bakery(expectProducts.ToArray());

            // Act
            actualBakery.Products = WorkWithArray.FindProductsCountMoreThanNumber(actualBakery, 3);

            // Assert
            Assert.Equal(expectedBakery, actualBakery);
        }
コード例 #11
0
        public ActionResult AddBill(Bill newbill)
        {
            var listbakery = Session["listCheckout"] as List <AddBakeryViewModel>;

            if (listbakery == null)
            {
                return(RedirectToAction("Shop", "Home"));
            }
            else
            {
                Bill bill = new Bill
                {
                    Id          = Guid.NewGuid().ToString(),
                    Nameuser    = newbill.Nameuser,
                    Addressuser = newbill.Addressuser,
                    Email       = newbill.Email,
                    SDT         = newbill.SDT
                };

                var billdetails = new List <Billdetails>();
                var dem         = 0;
                var tong        = 0;
                foreach (var item in listbakery)
                {
                    Bakery bakery     = db.Bakerys.Find(item.ID);
                    var    billdetail = new Billdetails()
                    {
                        Bakery    = bakery,
                        Bill      = bill,
                        iddetails = Guid.NewGuid().ToString(),
                        quality   = item.quantity
                    };
                    billdetails.Add(billdetail);
                    dem   = item.Price * item.quantity;
                    tong += dem;
                }

                bill.billdetails  = billdetails;
                bill.Totalprice   = tong;
                bill.confirmEmail = bill.Id;
                db.bill.Add(bill);
                db.SaveChanges();
                if (EmailService.sendEmailTocustomer(bill, Server))
                {
                    return(RedirectToAction("Thanks", "Home"));
                }
                else
                {
                    return(RedirectToAction("Shop", "Home"));
                }
            }
        }
コード例 #12
0
        public void InsertNewBakeryInTestDB()
        {
            Bakery testBakery = new Bakery();

            testBakery.Name    = "Perfect bakery";
            testBakery.Address = "Gothenburg";
            testBakery.Email   = "*****@*****.**";
            testBakery.Phone   = "111111";
            _bakeryService.Create(testBakery);
            Bakery bakeryFromDB = _bakeryService.GetById(testBakery.Id);

            testBakery.Should().BeEquivalentTo(bakeryFromDB);
        }
コード例 #13
0
        public void GetBakeryById()
        {
            string testGetById    = "5fb67c4a7db76a339046b22c";
            Bakery bakeryFromDB   = _bakeryService.GetById(testGetById);
            Bakery expectedBakery = new Bakery();

            expectedBakery.Id      = testGetById;
            expectedBakery.Name    = "Sweet Life";
            expectedBakery.Address = "Sweden, Gothenburg, Vasastan, 51a";
            expectedBakery.Email   = "*****@*****.**";
            expectedBakery.Phone   = "468822011771";
            expectedBakery.Should().BeEquivalentTo(bakeryFromDB);
        }
コード例 #14
0
        private static Baker GenerateBakery(Area area, int x, int y, string name)
        {
            var bakery = new Bakery(Guid.NewGuid(), "Bakery", area, x, y, 20, 20, true);
            var person = new Baker(Guid.NewGuid(), name, bakery);

            bakery.Owner = person;

            person.AddOwnerShip(bakery);
            person.Inventory.AddResource(new Coin(), 100);
            area.AddLocation(bakery);

            return(person);
        }
コード例 #15
0
 public ActionResult EditBakery(Bakery bakery, string nameimage)
 {
     if (ModelState.IsValid)
     {
         db.Entry(bakery).State = EntityState.Modified;
         var bajeryedit = db.Bakerys.SingleOrDefault(p => p.ID == bakery.ID);
         var image      = db.images.SingleOrDefault(p => p.Id == nameimage);
         bajeryedit.images = image;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(bakery));
 }
コード例 #16
0
        public void TestWorkWithFileOrderByCalorificValue()  // Тестирование метода  OrderByCalorificValue()
        {
            // Arrange
            List <Ingredient> ingredients = new List <Ingredient>()
            {
                new Ingredient("Вода", 0.2M, 0, 100),   // 0
                new Ingredient("Мука", 0.3M, 360, 350), // 1260
                new Ingredient("Масло", 1M, 884, 50)    // 442   1702
            };
            Production        production   = new Production("Батон", ingredients, 20);
            List <Ingredient> ingredients1 = new List <Ingredient>()
            {
                new Ingredient("Мука", 0.3M, 360, 350),  // 1260
                new Ingredient("Вода", 0.2M, 0, 100),    // 0
                new Ingredient("Дрожжи", 0.5M, 325, 25), // 81.25
                new Ingredient("Масло", 1M, 884, 50)     // 442  1783.25
            };
            Production        production1  = new Production("Хлеб", ingredients1, 15);
            List <Ingredient> ingredients2 = new List <Ingredient>()
            {
                new Ingredient("Мука", 0.3M, 360, 150),  // 540
                new Ingredient("Вода", 0.2M, 0, 200),    // 0
                new Ingredient("Дрожжи", 0.5M, 325, 50), // 162.5
                new Ingredient("Масло", 1M, 884, 100)    // 884  1586.5
            };
            Production        production2  = new Production("Хлеб Минский", ingredients2, 25);
            List <Ingredient> ingredients3 = new List <Ingredient>()
            {
                new Ingredient("Мука", 0.3M, 360, 350),    // 1260
                new Ingredient("Вода", 0.2M, 0, 100),      // 0
                new Ingredient("Масло", 1M, 884, 50),      // 442
                new Ingredient("Сахар", 0.7M, 325, 125),   // 406.25
                new Ingredient("Сгущенка", 0.2M, 416, 100) // 416 2524.25
            };
            Production        production3      = new Production("Плюшка со сгущенкой", ingredients3, 15);
            List <Production> expectedProducts = new List <Production> {
                production2, production, production1, production3
            };
            List <Production> testProducts = new List <Production> {
                production, production1, production2, production3
            };
            Bakery expectedBakery = new Bakery(expectedProducts.ToArray());
            Bakery testBakery     = new Bakery(testProducts.ToArray());

            // Act
            testBakery.Products = WorkWithArray.OrderByCalorificValue(testBakery);

            // Assert
            Assert.Equal(expectedBakery, testBakery);
        }
コード例 #17
0
        public void DeleteBakeryInTestDB()
        {
            Bakery testBakery = new Bakery();

            testBakery.Name    = "TO DELETE";
            testBakery.Address = "Gothenburg";
            testBakery.Email   = "*****@*****.**";
            testBakery.Phone   = "111111";
            _bakeryService.Create(testBakery);
            Bakery testbakeryFromDB = _bakeryService.GetById(testBakery.Id);

            _bakeryService.Remove(testbakeryFromDB);
            Assert.DoesNotContain(testbakeryFromDB, _bakeryService.Get());
        }
コード例 #18
0
        public ActionResult Details(string id)
        {
            if (id == null)
            {
                return(HttpNotFound());
            }
            Bakery bakery = db.Bakerys.Find(id);

            if (bakery == null)
            {
                return(HttpNotFound());
            }
            return(View(bakery));
        }
コード例 #19
0
        public ActionResult DeleteBakery(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Bakery bakery = db.Bakerys.Find(id);

            if (bakery == null)
            {
                return(HttpNotFound());
            }
            return(View(bakery));
        }
コード例 #20
0
        public Rating check(Bakery bakery, BakeryUser user)
        {
            if (user == null)
            {
                return(null);
            }
            var check = db.rates.Where(p => p.bakery.ID == bakery.ID && p.User.Id == user.Id).SingleOrDefault();

            if (check == null)
            {
                return(null);
            }
            return(check);
        }
コード例 #21
0
        public void TestFindProductsEqualsByPriceAndCalorificValue()  // Тестирование мотеда FindProductsEqualsByPriceAndCalorificValue()
        {
            // Arrange
            List <Ingredient> ingredients = new List <Ingredient>()
            {
                new Ingredient("Вода", 0.2M, 0, 100),
                new Ingredient("Мука", 0.3M, 360, 350),
                new Ingredient("Масло", 1M, 884, 50)
            };
            Production        production   = new Production("Батон", ingredients, 20);
            List <Ingredient> ingredients1 = new List <Ingredient>()
            {
                new Ingredient("Мука", 0.3M, 360, 350),
                new Ingredient("Вода", 0.2M, 0, 100),
                new Ingredient("Дрожжи", 0.5M, 325, 25),
                new Ingredient("Масло", 1M, 884, 50)
            };
            Production        production1  = new Production("Хлеб", ingredients1, 15);
            List <Ingredient> ingredients2 = new List <Ingredient>()
            {
                new Ingredient("Мука", 0.3M, 360, 150),
                new Ingredient("Вода", 0.2M, 0, 200),
                new Ingredient("Дрожжи", 0.5M, 325, 50),
                new Ingredient("Масло", 1M, 884, 100)
            };
            Production        production2  = new Production("Хлеб Минский", ingredients2, 25);
            List <Ingredient> ingredients3 = new List <Ingredient>()
            {
                new Ingredient("Мука", 0.3M, 360, 350),
                new Ingredient("Вода", 0.2M, 0, 100),
                new Ingredient("Масло", 1M, 884, 50),
                new Ingredient("Сахар", 0.7M, 325, 125),
                new Ingredient("Сгущенка", 0.2M, 416, 100)
            };
            Production        production3      = new Production("Плюшка со сгущенкой", ingredients3, 15);
            List <Production> expectedProducts = new List <Production> {
                production2
            };
            List <Production> testProducts = new List <Production> {
                production, production1, production2, production3
            };
            Bakery bakery = new Bakery(testProducts.ToArray());

            // Act
            Production[] productionArr = WorkWithArray.FindProductsEqualsByPriceAndCalorificValue(bakery, 2.62M, 1586f);

            // Assert
            Assert.Equal(expectedProducts.ToArray(), productionArr);
        }
コード例 #22
0
        public void UpdateBakeryInTestDB()
        {
            string updateTestId      = "5fb67c4a7db76a339046b22b";
            Bakery bakeryFromDB      = _bakeryService.GetById(updateTestId);
            Bakery BakeryWithNewData = new Bakery();

            BakeryWithNewData.Id      = bakeryFromDB.Id;
            BakeryWithNewData.Name    = "Update bakery " + bakeryFromDB.Name;
            BakeryWithNewData.Address = "Malmo";
            BakeryWithNewData.Email   = bakeryFromDB.Email;
            BakeryWithNewData.Phone   = bakeryFromDB.Phone;
            _bakeryService.Update(updateTestId, BakeryWithNewData);
            Bakery updatedBakery = _bakeryService.GetById(BakeryWithNewData.Id);

            Assert.Equal(BakeryWithNewData.Name, updatedBakery.Name);
        }
コード例 #23
0
        public JsonResult AddItem(string id)
        {
            var listbakery = Session["listCheckout"] as List <AddBakeryViewModel>;

            if (listbakery == null)
            {
                listbakery = new List <AddBakeryViewModel>();
            }


            var CheckExisit = listbakery.SingleOrDefault(p => p.ID == id);

            if (CheckExisit == null)
            {
                Bakery bakery = db.Bakerys.SingleOrDefault(p => p.ID == id);
                if (bakery == null)
                {
                    return(Json(new
                    {
                        status = 0,
                    }));
                }
                AddBakeryViewModel newBakeryadd = new AddBakeryViewModel()
                {
                    ID         = bakery.ID,
                    Bakeryname = bakery.Name,
                    nameimage  = bakery.images.nameImage,
                    quantity   = 1,
                    Price      = bakery.Price
                };

                listbakery.Add(newBakeryadd);
            }
            else
            {
                CheckExisit.quantity += 1;
            }
            Session["listCheckout"] = listbakery;
            var tongslhang = listbakery.Sum(p => p.quantity);

            return(Json(new
            {
                status = 1,
                data = listbakery,
                tongsl = tongslhang
            }));
        }
コード例 #24
0
ファイル: OrderBo.cs プロジェクト: dinhtuanhai/TMDT
        public void UpdateBakeryQuantity(Orders orders)
        {
            List <OrderDetail> listorder = _context.OrderDetail.Where(x => x.Idorder == orders.Id).ToList();

            foreach (var item in listorder)
            {
                Bakery bakery = _context.Bakery.FirstOrDefault(entry => entry.Id == item.Idbakery);
                if (bakery != null)
                {
                    _context.Entry(bakery).State = EntityState.Detached;
                    bakery.Quantity = bakery.Quantity - item.Quantity;
                }
                _context.Entry(bakery).State = EntityState.Modified;
            }

            _context.SaveChanges();
        }
コード例 #25
0
        public void TestFileReadFromFile()
        {
            // Arrange
            List <Ingredient> ingredients = new List <Ingredient>()
            {
                new Ingredient("Вода", 0.2M, 0, 100),
                new Ingredient("Мука", 0.3M, 360, 350),
                new Ingredient("Масло", 1M, 884, 50)
            };
            Production        production   = new Production("Батон", ingredients, 20);
            List <Ingredient> ingredients1 = new List <Ingredient>()
            {
                new Ingredient("Мука", 0.3M, 360, 350),
                new Ingredient("Вода", 0.2M, 0, 100),
                new Ingredient("Дрожжи", 0.5M, 325, 25),
                new Ingredient("Масло", 1M, 884, 50)
            };
            Production        production1  = new Production("Хлеб", ingredients1, 15);
            List <Ingredient> ingredients2 = new List <Ingredient>()
            {
                new Ingredient("Мука", 0.3M, 360, 150),
                new Ingredient("Вода", 0.2M, 0, 200),
                new Ingredient("Дрожжи", 0.5M, 325, 50),
                new Ingredient("Масло", 1M, 884, 100)
            };
            Production        production2  = new Production("Хлеб Минский", ingredients2, 25);
            List <Ingredient> ingredients3 = new List <Ingredient>()
            {
                new Ingredient("Мука", 0.3M, 360, 350),
                new Ingredient("Вода", 0.2M, 0, 100),
                new Ingredient("Масло", 1M, 884, 50),
                new Ingredient("Сахар", 0.7M, 325, 125),
                new Ingredient("Сгущенка", 0.2M, 416, 100)
            };
            Production        production3      = new Production("Плюшка со сгущенкой", ingredients3, 15);
            List <Production> expectedProducts = new List <Production> {
                production, production1, production2, production3
            };
            Bakery expectedBakery = new Bakery(expectedProducts.ToArray());

            // Act
            Bakery bakery = File.ReadFromFile(@"C:\Users\maxim\Documents\EPAM\Решения\EpamTask1\BakeryInfo.txt");

            // Assert
            Assert.Equal(expectedBakery, bakery);
        }
コード例 #26
0
        public bool AddBakery(string name, Category category, ImageModel image, int price, float VAT, int count)
        {
            Bakery newbakery = new Bakery
            {
                ID       = Guid.NewGuid().ToString(),
                ngaypost = DateTime.Now,
                Name     = name,
                category = category,
                Price    = price,
                VAT      = VAT,
                images   = image,
                count    = count
            };

            this.db.Bakerys.Add(newbakery);
            this.db.SaveChanges();
            return(true);
        }
コード例 #27
0
        public ActionResult EditBakery(AddBakeryViewModel bakery)
        {
            if (bakery.ID == null)
            {
                return(HttpNotFound());
            }
            Bakery newbakery = db.Bakerys.Find(bakery.ID);
            //   Category category = db.Categorys.Find(bakery.category_id);
            ImageModel image = db.images.Find(bakery.nameimage);

            if (newbakery == null)
            {
                return(HttpNotFound());
            }

            db.SaveChanges();
            return(View(newbakery));
        }
コード例 #28
0
        public ActionResult EditBakery(AddBakeryViewModel bakery)
        {
            if (bakery.ID == null)
            {
                return(HttpNotFound());
            }
            Bakery newbakery = bakeryreposibitory.find(bakery.ID);

            //   Category category = db.Categorys.Find(bakery.category_id);
            // ImageModel image = db.images.Find(bakery.nameimage);
            if (newbakery == null)
            {
                return(HttpNotFound());
            }


            return(View(newbakery));
        }
コード例 #29
0
        public void EditBakery(Bakery bakery, string Id)
        {
            var bajeryedit = db.Bakerys.SingleOrDefault(p => p.ID == bakery.ID);
            var image      = db.images.SingleOrDefault(p => p.Id == Id);

            bajeryedit.Name  = bakery.Name;
            bajeryedit.Price = bakery.Price;
            bajeryedit.VAT   = bakery.VAT;
            bajeryedit.count = bakery.count;
            if (bakery.category != null)
            {
                bajeryedit.category = bakery.category;
            }
            if (image != null)
            {
                bajeryedit.images = image;
            }
            db.SaveChanges();
        }
コード例 #30
0
        public void Test_MB11_14()
        {
            // Setup
            bool   isValidInput  = true;
            int    inputQuantity = 0;
            string strInput      = "14 MB11";

            string[] arrInputParts = null;
            Dictionary <string, Dictionary <int, double> > dicPacksWithRates = null;
            SortedDictionary <int, int> dicFinalPackSplitActual   = null;
            SortedDictionary <int, int> dicFinalPackSplitExpected = new SortedDictionary <int, int>();

            dicFinalPackSplitExpected.Add(2, 3);
            dicFinalPackSplitExpected.Add(5, 0);
            dicFinalPackSplitExpected.Add(8, 1);

            dicPacksWithRates = Bakery.DataSetup();

            // Execute Validation
            // Validate the input given by the user.
            Bakery.ValidateInput(ref strInput, ref isValidInput, ref inputQuantity, ref arrInputParts, ref dicPacksWithRates);

            // Assert Validation
            Assert.IsTrue(isValidInput);

            // Execute Order
            if (isValidInput)
            {
                // If input stays valid, then try processing the order.
                Bakery.ProcessOrder(ref inputQuantity, ref arrInputParts, ref dicPacksWithRates, out dicFinalPackSplitActual);
            }

            // Assert Order
            try
            {
                CollectionAssert.AreEqual(dicFinalPackSplitExpected, dicFinalPackSplitActual);
            }
            catch (AssertFailedException)
            {
                Assert.Fail();
            }
        }
コード例 #31
0
    public static void Main(string[] args)
    {
        System.Console.WriteLine("Bakery + Jar CCW COM test.");

        //IBakery Bakery = (IBakery) Factory.BakeryClass(); // TODO should be using this line. (?really?)
        Bakery bakery = new Bakery();
        Kitchen.Jar jar = new Kitchen.Jar();

        System.Console.WriteLine("Number of cookies in jar: " + jar.GetNumberCookies());
        System.Console.WriteLine("Baking 8 cookies.");
        bakery.bakeCookies(8, jar);

        System.Console.WriteLine("Number of cookies in jar: " + jar.GetNumberCookies());
        System.Console.WriteLine("Baking 3 cookies.");
        bakery.bakeCookies(3, jar);

        int totalCookiesBaked = bakery.getNumberCookiesBaked();
        if (11 != totalCookiesBaked) {
            System.Console.WriteLine("Error: Did not bake correct number of cookies.");
            throw new Exception("error"); // TODO right way
        } else {
            System.Console.WriteLine("Successfully baked a total of " + totalCookiesBaked + " cookies.");
        }
    }
コード例 #32
0
ファイル: Person.cs プロジェクト: henningms/cookie-bakery
 /// <summary>
 /// A new customer has entered.
 /// 
 /// </summary>
 /// <param name="name">Name of person</param>
 /// <param name="bakery">What bakery did he or she enter</param>
 public Person(String name, Bakery bakery)
 {
     Name = name;
     Bakery = bakery;
     _thread = new Thread(Grab);
 }
コード例 #33
0
ファイル: Customer.cs プロジェクト: Olsm/pg3300-innlevering
 // Set the customer name and bakery
 public Customer(String name, Bakery bakery)
 {
     Name = name;
     _bakery = bakery;
     Cookies = new List<ICookie>();
 }