protected void setUp()
        {
            //test a combination from 3 elements
            structure = new TestCasesStructure();
            Element          elem1 = new Element(structure);
            EquivalenceClass eq11  = new EquivalenceClass(elem1);
            EquivalenceClass eq12  = new EquivalenceClass(elem1);
            EquivalenceClass eq13  = new EquivalenceClass(elem1);
            Element          elem2 = new Element(structure);
            EquivalenceClass eq21  = new EquivalenceClass(elem2);
            EquivalenceClass eq22  = new EquivalenceClass(elem2);
            EquivalenceClass eq23  = new EquivalenceClass(elem2);
            Element          elem3 = new Element(structure);
            EquivalenceClass eq31  = new EquivalenceClass(elem3);
            EquivalenceClass eq32  = new EquivalenceClass(elem3);
            EquivalenceClass eq33  = new EquivalenceClass(elem3);

            dep = new Dependency(structure);
            foreach (Element element in structure.Elements)
            {
                dep.AddElement(element);
                foreach (EquivalenceClass equivalenceClass in element.EquivalenceClasses)
                {
                    dep.AddEquivalenceClass(equivalenceClass);
                }
            }

            combi1 = new Combination(dep);
            combi2 = new Combination(dep);
            combi3 = new Combination(dep);
            combi4 = new Combination(dep);

            combi1.AddEquivalenceClass(eq11);
            combi1.AddEquivalenceClass(eq22);
            combi1.AddEquivalenceClass(eq33);


            combi2.AddEquivalenceClass(eq21);
            combi2.AddEquivalenceClass(eq11);
            combi2.AddEquivalenceClass(eq32);

            combi3.AddEquivalenceClass(eq13);
            combi3.AddEquivalenceClass(eq23);
            combi3.AddCombination(combi4);

            test1 = new TestCase(structure);
            test2 = new TestCase(structure);


            test1.AddCombination(combi1);
            test1.AddEquivalenceClass(eq23);
            test1.AddEquivalenceClass(eq33);
            test1.AddCombination(combi4);

            test2.AddCombination(combi3);
            test2.AddCombination(combi4);
        }
        public void ICombinationsBean()
        {
            TestCase    tc   = new TestCase(to.TestCasesStruct);
            DefaultDAO  dao  = new DefaultDAO(to.TestCasesStruct);
            Dependency  dep  = new Dependency(to.TestCasesStruct);
            Combination comb = new Combination(dep);

            tc.AddCombination(comb);
            dao.Save();
            Assert.IsNotNull(dao.GetItem(tc.GetType(), tc.Id));
            Assert.IsNotNull(dao.GetItem(comb.GetType(), comb.Id));
            tc.RemoveCombination(comb);
            dep.RemoveCombination(comb);
            dao.DeleteItem(comb);
            to.TestCasesStruct.RemoveTestCase(tc);
            dao.DeleteItem(tc);
            to.TestCasesStruct.RemoveDependency(dep);
            dao.DeleteItem(dep);
        }
Example #3
0
        public void MergeCombinationsTest()
        {
            //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);
            Effect eff8 = new Effect(structure);
            Effect eff9 = new Effect(structure);

            dep2.Combinations[1].AddEffect(eff8);
            dep2.Combinations[2].AddEffect(eff9);
            test1.AddCombination(dep2.Combinations[2]);
            CombinationManager  cm     = new CombinationManager(dep2.Combinations[1]);
            IList <Combination> combis = cm.FindMergeableCombinations(eq33);

            cm.MergeCombinations(combis);
            Assert.AreEqual(1, combis.Count);
            Assert.IsTrue(combis.Contains(dep2.Combinations[2]));
            Assert.IsTrue(dep2.Combinations[1].Effects.Contains(eff9));
            Assert.IsTrue(dep2.Combinations[2].Effects.Contains(eff8));
            Assert.IsTrue(dep2.Combinations[1].Combinations.Contains(dep2.Combinations[2]));
            Assert.IsFalse(structure.TestCases.Contains(test1));
        }