Beispiel #1
0
        public void TestEqualsCategory()
        {
            string nameEq  = "leaf";
            string nameNeq = "leaf2";

            ICategory c1 = CategoryFactory.CreateCategory(nameEq, null);

            Assert.AreEqual(c1, c1);

            ICategory c2 = CategoryFactory.CreateCategory(nameEq, null);

            Assert.AreEqual(c1, c2);
            Assert.AreEqual(c2, c1);

            ICategory      c3   = CategoryFactory.CreateCategory(nameNeq, null);
            IGroupCategory root = CategoryFactory.CreateRoot("ROOT");
            ICategory      c4   = CategoryFactory.CreateCategory(nameEq, root);

            // Nome diverso
            Assert.AreNotEqual(c1, c3);
            Assert.AreNotEqual(c3, c1);
            // padre diverso
            Assert.AreNotEqual(c1, c4);
            Assert.AreNotEqual(c4, c1);
            Assert.AreNotEqual(c1, root);
            Assert.AreNotEqual(root, c1);
            Assert.AreNotEqual(c3, c4);
        }
Beispiel #2
0
        public void TestEqualsCategoryGroup()
        {
            string nameGEq  = "group";
            string nameGNEq = "group1";

            ICategory      l1      = CategoryFactory.CreateCategory(leafName, null);
            ICategory      l2      = CategoryFactory.CreateCategory(leafName, null);
            IGroupCategory g1      = CategoryFactory.CreateRoot(nameGEq);
            IGroupCategory gEqual  = CategoryFactory.CreateRoot(nameGEq);
            IGroupCategory gNEqual = CategoryFactory.CreateRoot(nameGNEq);

            // l1 | l2 | g1 | gEqual | gNEqual
            Assert.AreEqual(g1, g1);
            Assert.AreEqual(g1, gEqual);
            Assert.AreNotEqual(g1, gNEqual);

            // l2 | g1 -> l1 | gEqual | gNEqual
            //g1 ha un figlio mentre gEqual no
            g1.AddChild(l1);
            Assert.AreNotEqual(g1, gEqual);
            // g1 -> l1 | gEqual -> l2| gNEqual
            //(Confrontando i nomi e i path g1 e gEqual sono due gerarchie identifiche)
            gEqual.AddChild(l2);
            Assert.AreEqual(g1, gEqual);
            // gNEqual -> g1 -> l1 | gEqual -> l2
            // g1 ha un padre mentre l2 no, non sono due gerarchi identifiche
            g1.Parent = gNEqual;
            Assert.AreNotEqual(g1, gEqual);
            // gNEqual -> g1 -> l1 | gRoot -> gEqual -> l2
            //(Confrontando i nomi e i path sono due gerarchie identifiche)
            IGroupCategory gRoot = CategoryFactory.CreateRoot(nameGNEq);

            gEqual.Parent = gRoot;
            Assert.AreEqual(g1, gEqual);
        }
Beispiel #3
0
        public void TestPath()
        {
            string         pathLeafName = "\\" + leafName;
            string         pathRootName = "\\" + rootName;
            string         completePath = "\\" + rootName + "\\" + leafName;
            ICategory      l1           = CategoryFactory.CreateCategory(leafName, null);
            IGroupCategory rootC        = CategoryFactory.CreateRoot(rootName);

            Assert.IsTrue(l1.Path.CompareTo(pathLeafName) == 0);
            Assert.IsTrue(rootC.Path.CompareTo(pathRootName) == 0);
            l1.Parent = rootC;
            Assert.IsTrue(l1.Path.CompareTo(completePath) == 0);
        }
Beispiel #4
0
        protected override void Init()
        {
            base.Init();

            /* Cerco un file di configurazione delle categorie nel fileSystem,
             * se lo trovo carico le categorie contenute, altrimenti inizializzo
             * una nuova categoria
             */
            _root          = CategoryFactory.CreateRoot("ROOT");
            _root.Changed += OnCategoryChanged;

            /* Categorie HardCoded */
            IGroupCategory materiali = CategoryFactory.CreateGroup("materiali", _root);

            CategoryFactory.CreateCategory("testa", materiali);
            CategoryFactory.CreateCategory("staffa", materiali);
            IGroupCategory tessuto = CategoryFactory.CreateGroup("tessuto", materiali);

            CategoryFactory.CreateCategory("decorazioni", tessuto);

            IGroupCategory proprieta = CategoryFactory.CreateGroup("proprietà", _root);

            CategoryFactory.CreateCategory("impermeabilità", proprieta);
        }