Exemplo n.º 1
0
        public void CanCreateCategory()
        {
            const string nom         = "Tablette";
            const string description = "Tablette 7 pouces";
            var          categ       = FactoryCategory.CreateCategory(nom, description);

            new RepositoryCategory().Save(categ);
            new RepositoryCategory().Remove(categ);
        }
Exemplo n.º 2
0
    public GameObject GetItem(PoolID id)
    {
        //Return an instantiated object from the catalog
        if (Catalog.ContainsKey(id))
        {
            FactoryCategory category = Catalog[id];            //Get the current category
            GameObject      item     = category.GetRandomIten; //Get a random item

            return(Instantiate(item));                         //Return an instance of this object
        }
        else
        {
            Debug.LogError($"Missing key {id} from factory");
            return(null);
        }
    }
Exemplo n.º 3
0
 private void LoadFactories()
 {
     FactoryCategory category = new FactoryCategory("(General)");
     this._factoryCategories = new HybridDictionary(true);
     this._factoryCategories.Add("General", category);
     FactoryCategory category2 = category;
     ImageList list = new ImageList();
     ImageList list2 = new ImageList();
     list.ImageSize = new Size(0x20, 0x20);
     list.ColorDepth = ColorDepth.Depth32Bit;
     this._factoryListView.LargeImageList = list;
     list2.ImageSize = new Size(0x10, 0x10);
     list2.ColorDepth = ColorDepth.Depth32Bit;
     this._factoryListView.SmallImageList = list2;
     ImageList.ImageCollection images = list.Images;
     ImageList.ImageCollection images2 = list2.Images;
     foreach (IProjectFactory factory in this._creatableProjectFactories)
     {
         images.Add(factory.LargeIcon);
         images2.Add(factory.SmallIcon);
         FactoryListViewItem item = new FactoryListViewItem(factory, images.Count - 1);
         string str = factory.Category;
         if ((str == null) || (str.Length == 0))
         {
             category.Items.Add(item);
             continue;
         }
         FactoryCategory category3 = (FactoryCategory) this._factoryCategories[str];
         if (category3 != null)
         {
             category3.Items.Add(item);
         }
         else
         {
             category3 = new FactoryCategory(str);
             category3.Items.Add(item);
             this._factoryCategories.Add(str, category3);
         }
         if (string.Compare(str, this._initialCategory, true) == 0)
         {
             category2 = category3;
         }
     }
     FactoryCategory category4 = null;
     foreach (FactoryCategory category5 in this._factoryCategories.Values)
     {
         if (category5.Items.Count != 0)
         {
             this._categoryListBox.Items.Add(category5);
             if (category4 == null)
             {
                 category4 = category5;
             }
         }
     }
     if (category2.Items.Count == 0)
     {
         category2 = category4;
     }
     this._categoryListBox.SelectedItem = category2;
     this._categoryListBox.Focus();
 }
Exemplo n.º 4
0
        public void SetupStockMock()
        {
            InitDal.Init();
            var wilaya  = new RepositoryWilaya().FindAll().First(w => w.Name == "Tlemcen");
            var commune = new RepositoryWilaya().FindAll().First(w => w.Name == "Tlemcen").Communes.First(com => com.Name == "Tlemcen");
            var factoryStockCreateStock = FactoryStock.CreateStock("stock1", wilaya, commune, "Kiffane");

            // mock du stock
            var marque       = FactoryMarque.CreateMarque("Nom marque");
            var category     = FactoryCategory.CreateCategory("Nom category", "Description");
            var fournisseur1 = FactoryFournisseur.CreateFournisseur("Nom fournisseur");

            FactoryStock.CreateProductLine(factoryStockCreateStock, FactoryProduct.CreateProduct("product1", 15, category, marque, fournisseur1), 10);
            FactoryStock.CreateProductLine(factoryStockCreateStock, FactoryProduct.CreateProduct("product2", 17, category, marque, fournisseur1), 10);
            FactoryStock.CreateProductLine(factoryStockCreateStock, FactoryProduct.CreateProduct("product3", 20, category, marque, fournisseur1), 10);

            _stockMock = new Mock <IRepository <Stock, Guid> >();
            _stockMock.Setup(e => e.FindBy(It.IsAny <Query>())).Returns(
                new List <Stock> {
                factoryStockCreateStock
            }
                );

            // mock du secteur et client
            const string nomSect = "nom secteur1";
            var          sector  = FactorySector.CreateSector(nomSect, wilaya, commune);
            const string nom     = "NomClient1";
            const string prenom  = "PrenomClient1";

            FactorySector.CreateClient(nom, prenom, sector);
            _sectorMock = new Mock <IRepository <Sector, Guid> >();
            _sectorMock.Setup(e => e.FindBy(It.IsAny <Query>())).Returns(
                new List <Sector> {
                sector
            }
                );


            //mock du produit
            const string nommarque      = "Dell";
            var          marque2        = FactoryMarque.CreateMarque(nommarque);
            const string nom1           = "Desktop";
            const string description    = "Pc bureau";
            var          category2      = FactoryCategory.CreateCategory(nom1, description);
            const string nomfournisseur = "Solinf";
            var          fournisseur    = FactoryFournisseur.CreateFournisseur(nomfournisseur);
            var          produit1       = FactoryProduct.CreateProduct("MockedProduct", 10, category2, marque2, fournisseur);
            var          produit2       = FactoryProduct.CreateProduct("MockedProduct", 15, category2, marque2, fournisseur, "ce produit est explosif", reference: "http://www.google.com");

            _productMock = new Mock <IRepository <Product, Guid> >();
            _productMock.Setup(e => e.FindBy(It.IsAny <Query>())).Returns(
                new List <Product>
            {
                produit1,
                produit2
            }
                );
            const string nomSector = "secteur1";
            var          wilaya1   = new RepositoryWilaya().FindAll().First();
            var          commune1  = new RepositoryWilaya().FindAll().First().Communes.First();
            var          secteur   = FactorySector.CreateSector(nomSector, wilaya1, commune1);

            _sectorMock2 = new Mock <IRepository <Sector, Guid> >();
            _sectorMock2.Setup(e => e.FindBy(It.IsAny <Query>())).Returns(
                new List <Sector>
            {
                secteur
            }
                );
        }