Ejemplo n.º 1
0
        public ClientForm()
        {
            InitializeComponent();
            this.cblCategories.CheckOnClick = true;
            this._logicsService = new SmartShopLogics();
            this.RefreshData();
            this.SetAllCategoriesdCheckState(true);
            this.MatchGuiToUserType(this.CurrentUserType);
            this.rdbShowUserControls.Checked = true;
            this.psCommercials = new ShopSmart.Client.PictureSliderProccessor();

            this.InitCommercials();
        }
Ejemplo n.º 2
0
        public ClientForm()
        {
            InitializeComponent();
            this._logicsService = new SmartShopLogics();
            this.GetDbItems();
            this.BindSuperMarkets();
            this.BindCategories();
            this.BindProducts();
            this.SetAllCategoriesdCheckState(true);
            this.MatchGuiToUserType();

            //this.SetIcon();
        }
Ejemplo n.º 3
0
        public void GetAllProductsFromDbTest()
        {
            DataBase dataBase = Substitute.For<DataBase>();

            //Assign
            Supermarket sm;
            List<Category> categories;
            List<Product> products;
            SmartShopLogicsTests.CreateDataBaseObjects(out sm, out categories, out products);

            dataBase.GetAllProducts().Returns(products);
            SmartShopLogics bs = new SmartShopLogics(dataBase);

            int expectedProducts = products.Count;

            //act
            int actualNumberOfProducts = bs.GetAllProducts().Count;

            //assert
            Assert.IsTrue(expectedProducts == actualNumberOfProducts, String.Format("Got unexpected number of products ({0} instead of {1})",actualNumberOfProducts,expectedProducts));
        }
Ejemplo n.º 4
0
        public void GetAllSuperMarketsFromDbTest()
        {
            DataBase dataBase = Substitute.For<DataBase>();

            //Assign
            Random rnd = new Random(1);
            int expected = rnd.Next(1000);

            List<Supermarket> superMarkets = new List<Supermarket>();
            for (int i = 0; i < expected; i++)
            {
                Supermarket sm = new Supermarket() { Id = i, Name = "Supermarket " + i };
                superMarkets.Add(sm);
            }

            dataBase.GetAllSuperMarkets().Returns(superMarkets);
            SmartShopLogics bs = new SmartShopLogics(dataBase);

            expected = superMarkets.Count;

            //act
            int actual = bs.GetAllSuperMarkets().Count;

            //assert
            Assert.IsTrue(expected == actual, String.Format("Got unexpected number of superMarkets ({0} instead of {1}",actual,expected));
        }
Ejemplo n.º 5
0
        public void SortedGivenShopListTest()
        {
            //Assign
            Supermarket sm;
            List<Category> categories;
            List<Product> products;
            SmartShopLogicsTests.CreateDataBaseObjects(out sm, out categories, out products);

            ShopList list = new ShopList();
            #region Populating shopping list
            list.Supermarket = sm;
            list.SuperMarketId = sm.Id;
            for (int i = 0; i < products.Count; i++)
            {
                Product currProduct = products[i];
                ShoplistItem newItem = new ShoplistItem() { Product = currProduct, Quantity = i, ShopList = list };
                list.ShoplistItems.Add(newItem);
            }
            #endregion

            //act
            DataBase dataBase = Substitute.For<DataBase>();
            SmartShopLogics bs = new SmartShopLogics(dataBase);
            ShopList sorted = bs.GetSortedList(list);

            //assert
            int lastCategoryId = -1;
            for (int i = 0; i < sorted.ShoplistItems.Count; i++)
            {
                List<ShoplistItem> items = sorted.ShoplistItems.ToList();
                int currCategory = items[i].Product.Category.CategorySorts.Where(cat => cat.Supermarket == sm).SingleOrDefault().SortValue;
                //If list is sorted, the sort value should always increase
                Assert.IsTrue(currCategory >= lastCategoryId, "Shopping list was not sorted properly ({0} sort value came before {1})",lastCategoryId, currCategory);
                lastCategoryId = currCategory;

            }
        }
Ejemplo n.º 6
0
 private void InitSessionVariables()
 {
     var logics = new SmartShopLogics();
     Application[SessionKeys.LOGICS] = logics;
 }