Ejemplo n.º 1
0
        public TestCaseResult GetResultForCase2()
        {
            //        Input 2:
            //        1 imported box of chocolates at 10.00
            //        1 imported bottle of perfume at 47.50

            //        Output 2:
            //        1 imported box of chocolates: 10.50
            //        1 imported bottle of perfume: 54.65
            //        Sales Taxes: 7.65
            //        Total: 65.15
            ShoppingCart shoppingCart = new ShoppingCart(taxationstrategy);

            Good importGood1 = new ImportedGood(new GoodFactory(GoodType.FOOD).getGood("imported box of chocolates", 10.00M));
            Good importGood2 = new ImportedGood(new GoodFactory(GoodType.GENERIC).getGood("imported bottle of perfume", 47.50M));
            Good book        = new GoodFactory(GoodType.BOOK).getGood("book", 12.49M);

            shoppingCart.add(1, importGood1);
            shoppingCart.add(1, importGood2);

            shoppingCart.printReceipt();

            return(new TestCaseResult()
            {
                Taxes = shoppingCart.getSalesTaxes(),
                TotalPrice = shoppingCart.getTotalPrice()
            });
        }
Ejemplo n.º 2
0
        public TestCaseResult GetResultForCase3()
        {
            //        Input 3:
            //        1 imported bottle of perfume at 27.99
            //        1 bottle of perfume at 18.99
            //        1 packet of headache pills at 9.75
            //        1 box of imported chocolates at 11.25

            //        Output 3:
            //        1 imported bottle of perfume: 32.19
            //        1 bottle of perfume: 20.89
            //        1 packet of headache pills: 9.75
            //        1 imported box of chocolates: 11.85
            //        Sales Taxes: 6.70
            //        Total: 74.68

            ShoppingCart shoppingCart = new ShoppingCart(taxationstrategy);

            Good importGood1 = new ImportedGood(new GoodFactory(GoodType.GENERIC).getGood("imported bottle of perfume", 27.99M));
            Good normalGood1 = new GoodFactory(GoodType.GENERIC).getGood("bottle of perfume", 18.99M);
            Good normalGood2 = new GoodFactory(GoodType.MEDICAL).getGood("packet of headache pills", 9.75M);
            Good importGood2 = new ImportedGood(new GoodFactory(GoodType.FOOD).getGood("imported box of chocolates", 11.25M));

            shoppingCart.add(1, importGood1);
            shoppingCart.add(1, normalGood1);
            shoppingCart.add(1, normalGood2);
            shoppingCart.add(1, importGood2);
            shoppingCart.printReceipt();

            return(new TestCaseResult()
            {
                Taxes = shoppingCart.getSalesTaxes(),
                TotalPrice = shoppingCart.getTotalPrice()
            });
        }
Ejemplo n.º 3
0
        public void checkAddTour()
        {
            string[] goods = new string[10];
            goods[0] = "2";
            goods[1] = "goods";
            goods[2] = "Type ";
            goods[3] = "35500";
            goods[4] = "Доллар";

            TypeGoodsForm contr = new TypeGoodsForm();

            TypeGoodsForm.dataTypeGoods.Rows.Add("1", "Саморез");
            TypeGoodsCol obj = new TypeGoodsCol();

            GoodsForm formTour = new GoodsForm();

            GoodsForm.dataGoods.Rows.Add("1", "goods", "VIP туры", "12000", "Рубль");

            GoodsTypeCol tourtype = new GoodsTypeCol();

            GoodFactory factTour = new GoodFactory();
            int         a        = GoodFactory.count();

            GoodFactory.Add_Goods(goods);
            Assert.AreEqual(a + 1, GoodFactory.count());
        }
Ejemplo n.º 4
0
        //Test case1
        public TestCaseResult GetResultForCase1()
        {
            //        Input 1:
            //        1 book at 12.49
            //        1 music CD at 14.99
            //        1 chocolate bar at 0.85

            //        Output 1:
            //        1 book : 12.49
            //        1 music CD: 16.49
            //        1 chocolate bar: 0.85
            //        Sales Taxes: 1.50
            //        Total: 29.83
            ShoppingCart shoppingCart = new ShoppingCart(taxationstrategy);
            Good         book         = new GoodFactory(GoodType.BOOK).getGood("book", 12.49M);
            Good         generic      = new GoodFactory(GoodType.GENERIC).getGood("music CD", 14.99M);
            Good         food         = new GoodFactory(GoodType.FOOD).getGood("chocolate bar", 0.85M);

            shoppingCart.add(1, book);
            shoppingCart.add(1, generic);
            shoppingCart.add(1, food);
            shoppingCart.printReceipt();

            return(new TestCaseResult()
            {
                Taxes = shoppingCart.getSalesTaxes(),
                TotalPrice = shoppingCart.getTotalPrice()
            });
        }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            //---Fabryka Abstrakcyjna---
            Console.WriteLine("---Fabryka abstrakcyjna---");
            IQueryAbstractFactory goodQueryFactory = new GoodAbstractFactory();
            DbQuery goodQuery = new DbQuery(goodQueryFactory, new Good {
                Name = "Krakowska sucha"
            });

            Console.WriteLine(goodQuery.GetInsert());
            Console.WriteLine(goodQuery.GetSelect());

            IQueryAbstractFactory contractorQueryFactory = new ContractorAbstractFactory();
            DbQuery contractorQuery = new DbQuery(contractorQueryFactory, new Contractor {
                Name = "Atlas"
            });

            Console.WriteLine(contractorQuery.GetInsert());
            Console.WriteLine(contractorQuery.GetSelect());

            //---Metoda wytwórcza---
            Console.WriteLine("\n\n---Metoda wytwórcza---");
            IQueryFactory factory = new ContractorFactory();
            DbQuery       db      = new DbQuery(factory, new Contractor {
                Name = "M&H"
            });

            Console.WriteLine(db.GetInsert());
            Console.WriteLine(db.GetSelect());

            factory = new GoodFactory();
            db      = new DbQuery(factory, new Good {
                Name = "Kaszanka"
            });
            Console.WriteLine(db.GetInsert());
            Console.WriteLine(db.GetSelect());


            //---Prosta Fabryka---
            Console.WriteLine("\n\n---Prosta fabryka---");
            DbQuery goodQuerySimple = new DbQuery(new Good {
                Name = "Mielonka"
            });

            Console.WriteLine(goodQuerySimple.GetInsert());
            Console.WriteLine(goodQuerySimple.GetSelect());
            goodQuerySimple = new DbQuery(new Contractor {
                Name = "Sonny"
            });
            Console.WriteLine(goodQuerySimple.GetInsert());
            Console.WriteLine(goodQuerySimple.GetSelect());


            Console.ReadKey();
        }
Ejemplo n.º 6
0
        public void CheckGoodIdsDiffrent()
        {
            var factory = new GoodFactory(name, desc, category);

            var instance1 = factory.Instance;
            var instance2 = factory.Instance;

            Assert.AreNotSame(instance1, instance2);
            Assert.AreNotEqual(instance1.Id, instance2.Id);
            Assert.AreEqual(instance2.Id, instance1.Id + 1);
        }
Ejemplo n.º 7
0
        public void CheckGoodGeneration()
        {
            var factory = new GoodFactory(name, desc, category);

            var instance = factory.Instance;

            Assert.NotNull(instance);
            Assert.AreEqual(instance.Name, name);
            Assert.AreEqual(instance.Description, desc);
            Assert.AreEqual(category, instance.Category);
            Assert.Greater(instance.Id, -1);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Tries the parse.
        /// </summary>
        /// <returns><c>true</c>, if parse was tryed, <c>false</c> otherwise.</returns>
        /// <param name="repr">Repr.</param>
        /// <param name="good">Good.</param>
        public static bool TryParse(string repr, out GoodFactory good)
        {
            var split = repr.Split(new[] { ';' });

            good = null;
            if (split.Length != 3)
            {
                return(false);
            }

            good = new GoodFactory(split[0], split[1], split[2]);
            return(true);
        }
Ejemplo n.º 9
0
        public void CreateTest()
        {
            var r = GetRandom.Object <GoodsData>();

            var o = GoodFactory.Create(r.ID, r.Name, r.Code, r.Description, r.Price, r.Type, r.ImgData,
                                       r.ImgName, r.ValidFrom, r.ValidTo);

            Assert.AreEqual(r.Name, o.Data.Name);
            Assert.AreEqual(r.ID, o.Data.ID);
            Assert.AreEqual(r.Description, o.Data.Description);
            Assert.AreEqual(r.Code, o.Data.Code);
            Assert.AreEqual(r.Price, o.Data.Price);
            Assert.AreEqual(r.Type, o.Data.Type);
            Assert.AreEqual(r.ImgData, o.Data.ImgData);
            Assert.AreEqual(r.ImgName, o.Data.ImgName);
            Assert.AreEqual(r.ValidFrom, o.Data.ValidFrom);
            Assert.AreEqual(r.ValidTo, o.Data.ValidTo);
        }
Ejemplo n.º 10
0
        public void checkAddOrder()
        {
            string[] order = new string[5];
            order[0] = "225";
            order[1] = "Petr";
            order[2] = "Vasya";
            order[3] = "12 may 2013";
            order[4] = "goods";

            Clients formCL = new Clients();

            Clients.dataClients.Rows.Add("1", "Pet", "*****@*****.**", "88-88", "12 may 1990", "VIP");
            ClientTypeCol col    = new ClientTypeCol();
            ClientFactory factCl = new ClientFactory();

            managers formMan = new managers();

            managers.dataManagers.Rows.Add("1", "Petya", "8888", "Менеджер", "petya", " 22 мая");
            ManagerTypeCol coll    = new ManagerTypeCol();
            ManagerFactory factMan = new ManagerFactory();

            OrdersForm formOrd = new OrdersForm();

            OrdersForm.dataOrders.Rows.Add("Pet", "Petya", "12 may 2015", "1", "Goods1");
            OrdersForm.dataOrders.Rows.Add("Pet", "Petya", "13 may 2014", "2", "Goods2");
            OrdersForm.dataOrders.Rows.Add("Pet", "Petya", "14 may 2014", "3", "Goods3");

            TypeGoodsForm type = new TypeGoodsForm();

            TypeGoodsForm.dataTypeGoods.Rows.Add("1", "Саморез");
            TypeGoodsCol obj = new TypeGoodsCol();

            GoodsTypeCol goodstype = new GoodsTypeCol();

            GoodsForm formGoods = new GoodsForm();

            GoodsForm.dataGoods.Rows.Add("1", "goods", "type", "12000", "Рубль");
            GoodFactory  factTour = new GoodFactory();
            OrderFactory fact     = new OrderFactory();
            int          a        = OrderFactory.count();

            OrderFactory.AddOrder(order);
            Assert.AreEqual(a + 1, OrderFactory.count());
        }
Ejemplo n.º 11
0
        public void checkDelTour()
        {
            TypeGoodsForm contr = new TypeGoodsForm();

            TypeGoodsForm.dataTypeGoods.Rows.Add("1", "Саморез");
            TypeGoodsCol obj = new TypeGoodsCol();

            GoodsForm formTour = new GoodsForm();

            GoodsForm.dataGoods.Rows.Add("1", "goods", "Type", "12000", "Рубль");
            GoodsForm.dataGoods.Rows.Add("2", "goods", "Type", "12000", "Рубль");
            GoodsForm.dataGoods.Rows.Add("3", "goods", "Type", "12000", "Рубль");

            GoodsTypeCol tourtype = new GoodsTypeCol();

            GoodFactory factTour = new GoodFactory();
            int         a        = GoodFactory.count();

            GoodFactory.DeleteGoods(1);
            Assert.AreEqual(a - 1, GoodFactory.count());
        }
Ejemplo n.º 12
0
        public async Task <IActionResult> Create([Bind(properties)] GoodView c, IFormFile file)
        {
            if (!ModelState.IsValid)
            {
                return(View(c));
            }

            var(imgData, imgName) = FileHelper.ParseImageToBytes(file);

            c.ID   = Guid.NewGuid().ToString();
            c.Code = GetRandom.Code();
            await changeCodeIfInUse(c.Code, c);

            await validateId(c.ID, ModelState);

            var o = GoodFactory.Create(c.ID, c.Name, c.Code, c.Description, c.Price, c.Type,
                                       imgData, imgName);

            await repository.AddObject(o);

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 13
0
        public void CreateWithNullTest()
        {
            var o = GoodFactory.Create(null);

            Assert.IsNotNull(o);
        }
Ejemplo n.º 14
0
 protected override Good createObject(GoodsData r) => GoodFactory.Create(r);