示例#1
0
        public void GenerateUpdateDeleteEquivalence()
        {
            CompoundEdit ce = new CompoundEdit();

            IGenerator gen = new PermutationCombinationsGenerator(dep, 80000, CombinationsGenerationOption.OVERWRITE);

            ce.AddEdit(gen.Generate());
            //deleting an equivalence
            IGenerator genUpdater = new PermutationCombinationsGenerator(dep, 80000, CombinationsGenerationOption.UPDATE);

            ce.AddEdit(EditFactory.instance.CreateRemoveEquivalenceClassEdit(dep, eq12));
            dep.RemoveEquivalenceClass(eq12);
            ce.AddEdit(genUpdater.Generate());
            Assert.AreEqual(18, dep.Combinations.Count);

            Assert.AreEqual(10, dep.Combinations[9].Position);
            Assert.IsTrue(dep.Combinations[9].EquivalenceClasses.Contains(eq13));
            Assert.IsTrue(dep.Combinations[9].EquivalenceClasses.Contains(eq21));
            Assert.IsTrue(dep.Combinations[9].EquivalenceClasses.Contains(eq31));
            //add a new equivalence
            ce.AddEdit(EditFactory.instance.CreateRemoveEquivalenceClassEdit(dep, eq24));
            dep.AddEquivalenceClass(eq24);
            ce.AddEdit(genUpdater.Generate());
            Assert.AreEqual(24, dep.Combinations.Count);
            Assert.AreEqual(10, dep.Combinations[9].Position);
            Assert.IsTrue(dep.Combinations[9].EquivalenceClasses.Contains(eq11));
            Assert.IsTrue(dep.Combinations[9].EquivalenceClasses.Contains(eq24));
            Assert.IsTrue(dep.Combinations[9].EquivalenceClasses.Contains(eq31));
            ce.EndAllEdits();
            ce.Undo();
            Assert.IsTrue(dep.Combinations.Count == 0);
        }
示例#2
0
        public void GenerateOverwrite()
        {
            CompoundEdit ce  = new CompoundEdit();
            IGenerator   gen = new PermutationCombinationsGenerator(dep, 80000, CombinationsGenerationOption.OVERWRITE);

            ce.AddEdit(gen.Generate());

            Assert.AreEqual(27, dep.Combinations.Count);
            Assert.AreEqual(1, dep.Combinations[0].Position);
            Assert.IsTrue(dep.Combinations[0].EquivalenceClasses.Contains(eq11));
            Assert.IsTrue(dep.Combinations[0].EquivalenceClasses.Contains(eq21));
            Assert.IsTrue(dep.Combinations[0].EquivalenceClasses.Contains(eq31));

            Assert.AreEqual(2, dep.Combinations[1].Position);
            Assert.IsTrue(dep.Combinations[1].EquivalenceClasses.Contains(eq11));
            Assert.IsTrue(dep.Combinations[1].EquivalenceClasses.Contains(eq21));
            Assert.IsTrue(dep.Combinations[1].EquivalenceClasses.Contains(eq32));

            Assert.AreEqual(19, dep.Combinations[18].Position);
            Assert.IsTrue(dep.Combinations[18].EquivalenceClasses.Contains(eq13));
            Assert.IsTrue(dep.Combinations[18].EquivalenceClasses.Contains(eq21));
            Assert.IsTrue(dep.Combinations[18].EquivalenceClasses.Contains(eq31));

            ce.EndAllEdits();
            ce.Undo();
            Assert.IsTrue(dep.Combinations.Count == 0);
        }
示例#3
0
        public void FindMergeableCombinationsTest()
        {
            //generate combinations
            CompoundEdit ce   = new CompoundEdit();
            Dependency   dep2 = new Dependency(structure);

            foreach (Element element in structure.Elements)
            {
                dep2.AddElement(element);
                foreach (EquivalenceClass equivalenceClass in element.EquivalenceClasses)
                {
                    dep2.AddEquivalenceClass(equivalenceClass);
                }
            }
            IGenerator gen = new PermutationCombinationsGenerator(dep2, 80000, CombinationsGenerationOption.OVERWRITE);

            //this generates 27 combinations
            ce.AddEdit(gen.Generate());
            //select the combination 02
            Assert.AreEqual(dep2.Combinations[1].Position, 2);
            CombinationManager  cm     = new CombinationManager(dep2.Combinations[1]);
            IList <Combination> combis = cm.FindMergeableCombinations(eq33);

            Assert.AreEqual(1, combis.Count);
            Assert.IsTrue(combis.Contains(dep2.Combinations[2]));
            CombinationManager cm1 = new CombinationManager(dep2.Combinations[0]);

            combis = cm1.FindMergeableCombinations(eq23);
            Assert.AreEqual(1, combis.Count);
            Assert.IsTrue(combis.Contains(dep2.Combinations[6]));
        }
示例#4
0
        public void UnMergeCombinationsTest()
        {
            //generate a 3 x 3 permutation
            CompoundEdit ce   = new CompoundEdit();
            Dependency   dep2 = new Dependency(structure);

            foreach (Element element in structure.Elements)
            {
                if (element.Position == 3)
                {
                    continue;
                }
                dep2.AddElement(element);
                foreach (EquivalenceClass equivalenceClass in element.EquivalenceClasses)
                {
                    dep2.AddEquivalenceClass(equivalenceClass);
                }
            }

            IGenerator gen = new PermutationCombinationsGenerator(dep2, 80000, CombinationsGenerationOption.OVERWRITE);

            //this generates 10 combinations
            ce.AddEdit(gen.Generate());
            //select the combination 02
            Assert.AreEqual(dep2.Combinations.Count, 9);

            CombinationManager cm = new CombinationManager(dep2.Combinations[0]);

            IList <Combination> combis = cm.FindMergeableCombinations(eq12);

            cm.MergeCombinations(combis);
            Assert.IsTrue(dep2.Combinations[0].Combinations.Contains(dep2.Combinations[3]));
            combis = cm.FindMergeableCombinations(eq13);
            cm.MergeCombinations(combis);
            Assert.IsTrue(dep2.Combinations[0].Combinations.Contains(dep2.Combinations[6]));
            combis = cm.FindMergeableCombinations(eq22);
            cm.MergeCombinations(combis);
            Assert.IsTrue(dep2.Combinations[0].Combinations.Contains(dep2.Combinations[4]));
            Assert.IsTrue(dep2.Combinations[0].Combinations.Contains(dep2.Combinations[7]));
            Assert.IsFalse(dep2.Combinations[0].Combinations.Contains(dep2.Combinations[8]));
            combis = cm.FindMergeableCombinations(eq23);
            cm.MergeCombinations(combis);
            Assert.IsTrue(dep2.Combinations[0].Combinations.Contains(dep2.Combinations[2]));
            Assert.IsTrue(dep2.Combinations[0].Combinations.Contains(dep2.Combinations[5]));
            Assert.IsTrue(dep2.Combinations[0].Combinations.Contains(dep2.Combinations[8]));

            //now the unmerge
            cm.UnMergeCombinations(eq22);
            Assert.IsFalse(dep2.Combinations[0].Combinations.Contains(dep2.Combinations[1]));
            Assert.IsTrue(dep2.Combinations[1].Combinations.Contains(dep2.Combinations[4]));
            Assert.IsTrue(dep2.Combinations[1].Combinations.Contains(dep2.Combinations[7]));
            Assert.IsTrue(dep2.Combinations[0].Combinations.Contains(dep2.Combinations[3]));
            //this thows an arg exception
            cm.UnMergeCombinations(eq11);
            cm.UnMergeCombinations(eq13);
            Assert.IsFalse(dep2.Combinations[0].Combinations.Contains(dep2.Combinations[8]));
            Assert.IsTrue(dep2.Combinations[8].Combinations.Contains(dep2.Combinations[5]));
        }
示例#5
0
        public void UnMergeCombinationsTest2()
        {
            //generate a 3 x 3 permutation
            CompoundEdit ce   = new CompoundEdit();
            Dependency   dep2 = new Dependency(structure);

            dep = dep2;
            foreach (Element element in structure.Elements)
            {
                if (element.Position == 3)
                {
                    continue;
                }
                dep2.AddElement(element);
                foreach (EquivalenceClass equivalenceClass in element.EquivalenceClasses)
                {
                    dep2.AddEquivalenceClass(equivalenceClass);
                }
            }

            IGenerator gen = new PermutationCombinationsGenerator(dep2, 80000, CombinationsGenerationOption.OVERWRITE);

            //this generates 10 combinations
            ce.AddEdit(gen.Generate());
            //Merge
            //merge combination c3 with eq22
            CombinationManager  cm     = new CombinationManager(dep2.Combinations[2]);
            IList <Combination> combis = cm.FindMergeableCombinations(eq22);

            cm.MergeCombinations(combis);
            Assert.IsTrue(dep2.Combinations[2].Combinations.Contains(dep2.Combinations[1]));
            //merge combination c3 with eq21

            combis = cm.FindMergeableCombinations(eq21);
            cm.MergeCombinations(combis);
            Assert.IsTrue(dep.Combinations[2].Combinations.Contains(dep2.Combinations[1]));

            //merge combination c6 with eq22
            CombinationManager cm2 = new CombinationManager(dep2.Combinations[5]);

            combis = cm2.FindMergeableCombinations(eq22);
            cm2.MergeCombinations(combis);
            Assert.IsTrue(dep2.Combinations[5].Combinations.Contains(dep2.Combinations[4]));

            //merge combination c6 with eq21
            combis = cm2.FindMergeableCombinations(eq21);
            cm2.MergeCombinations(combis);
            Assert.IsTrue(dep2.Combinations[5].Combinations.Contains(dep2.Combinations[3]));


            //merge combination c9 with eq22
            CombinationManager cm4 = new CombinationManager(dep.Combinations[8]);

            combis = cm4.FindMergeableCombinations(eq22);
            cm4.MergeCombinations(combis);
            Assert.IsTrue(dep2.Combinations[8].Combinations.Contains(dep2.Combinations[7]));

            //merge combination c9 with eq21

            combis = cm4.FindMergeableCombinations(eq21);
            cm4.MergeCombinations(combis);
            Assert.IsTrue(dep2.Combinations[8].Combinations.Contains(dep2.Combinations[6]));

            //merge combination c9 with eq12

            combis = cm4.FindMergeableCombinations(eq12);
            cm4.MergeCombinations(combis);
            Assert.IsTrue(dep2.Combinations[8].Combinations.Contains(dep2.Combinations[5]));

            //merge combination c9 with eq11

            combis = cm4.FindMergeableCombinations(eq11);
            cm4.MergeCombinations(combis);
            Assert.IsTrue(dep2.Combinations[8].Combinations.Contains(dep2.Combinations[2]));

            //unmerge from C9 eq11
            cm4.UnMergeCombinations(eq11);
            Assert.IsFalse(dep2.Combinations[0].Combinations.Contains(dep2.Combinations[0]));
            cm4.UnMergeCombinations(eq21);

            CombinationManager cm5 = new CombinationManager(dep.Combinations[2]);

            //unmerge from C3 eq22
            cm5.UnMergeCombinations(eq22);
        }