Beispiel #1
0
        public void TestFSM2PN1()
        {
            var fsm = new FSM.FiniteStateMachine()
            {
                ID = "Test"
            };

            var state1 = new FSM.State()
            {
                Name = "Zustand 1",
                IsStartState = true
            };

            var state2 = new FSM.State()
            {
                Name = "Zustand 2",
                IsEndState = true
            };

            var transition1 = new FSM.Transition()
            {
                StartState = state1,
                EndState = state1,
                Input = "a"
            };

            var transition2 = new FSM.Transition()
            {
                StartState = state1,
                EndState = state2,
                Input = "b"
            };

            var transition3 = new FSM.Transition()
            {
                StartState = state2,
                EndState = state1,
                Input = "a"
            };

            state1.Transitions.Add(transition1);
            state1.Transitions.Add(transition2);
            state2.Transitions.Add(transition3);

            fsm.States.Add(state1);
            fsm.States.Add(state2);
            fsm.Transitions.Add(transition1);
            fsm.Transitions.Add(transition2);
            fsm.Transitions.Add(transition3);

            var context = new TransformationContext(transformation);
            var pn = TransformationEngine.Transform<FSM.FiniteStateMachine, PN.PetriNet>(fsm, context);

            Assert.AreEqual(fsm, context.Input[0]);
            Assert.AreEqual(pn, context.Output);

            AssertSimilar(fsm, pn, context.Trace);
        }
Beispiel #2
0
        public void InitTestContext()
        {
            ruleT1 = new TestOutputRuleT1();
            ruleT2 = new TestOutputRuleT2();
            otherT1 = new TestOutputRuleT1();
            otherT2 = new TestOutputRuleT2();

            transformation = new MockTransformation(ruleT1, ruleT2, otherT1, otherT2);
            context = new TransformationContext(transformation);
        }
        public void Initialize()
        {
            ruleT1 = new TestRuleT1();
            ruleT2 = new TestRuleT2();
            ruleTN = new TestRuleTN();

            transformation = new MockTransformation(ruleT1, ruleT2, ruleTN);

            pattern = new TestPattern();

            transformation.Patterns.Add(pattern);

            context = new TransformationContext(transformation);
        }
        public void Transformations_Persons2FamilyRelations1()
        {
            var root = CreateSimpsons();
            var context = new TransformationContext(transformation);
            var simpsons = TransformationEngine.Transform<Ps.Root, Fam.Root>(root, context);

            Assert.AreEqual(root, context.Input[0]);
            Assert.AreEqual(simpsons, context.Output);

            var abraham = LookupMale("Abraham", context);
            var mona = LookupFemale("Mona", context);
            var clancy = LookupMale("Clancy", context);
            var jackeline = LookupFemale("Jackeline", context);
            var herb = LookupMale("Herb", context);
            var homer = LookupMale("Homer", context);
            var marge = LookupFemale("Marge", context);
            var patty = LookupFemale("Patty", context);
            var selma = LookupFemale("Selma", context);
            var bart = LookupMale("Bart", context);
            var lisa = LookupFemale("Lisa", context);
            var maggie = LookupFemale("Maggie", context);
            var ling = LookupFemale("Ling", context);

            abraham.AssertNotNull();
            mona.AssertNotNull();
            clancy.AssertNotNull();
            jackeline.AssertNotNull();
            herb.AssertNotNull();
            homer.AssertNotNull();
            marge.AssertNotNull();
            patty.AssertNotNull();
            selma.AssertNotNull();
            bart.AssertNotNull();
            lisa.AssertNotNull();
            maggie.AssertNotNull();
            ling.AssertNotNull();

            //abraham
            Assert.AreEqual(mona, abraham.Wife);
            abraham.Father.AssertNull();
            abraham.Mother.AssertNull();
            abraham.Sisters.AssertEmpty();
            abraham.Brothers.AssertEmpty();
            abraham.Uncles.AssertEmpty();
            abraham.Aunts.AssertEmpty();
            abraham.Sons.AssertContainsOnly(herb, homer);
            abraham.Daughters.AssertEmpty();
            //mona
            Assert.AreEqual(abraham, mona.Husband);
            mona.Father.AssertNull();
            mona.Mother.AssertNull();
            mona.Sisters.AssertEmpty();
            mona.Brothers.AssertEmpty();
            mona.Aunts.AssertEmpty();
            mona.Uncles.AssertEmpty();
            mona.Sons.AssertContainsOnly(herb, homer);
            mona.Daughters.AssertEmpty();
            //clancy
            Assert.AreEqual(jackeline, clancy.Wife);
            clancy.Father.AssertNull();
            clancy.Mother.AssertNull();
            clancy.Sisters.AssertEmpty();
            clancy.Brothers.AssertEmpty();
            clancy.Aunts.AssertEmpty();
            clancy.Uncles.AssertEmpty();
            clancy.Sons.AssertEmpty();
            clancy.Daughters.AssertContainsOnly(marge, patty, selma);
            //jackeline
            Assert.AreEqual(clancy, jackeline.Husband);
            jackeline.Father.AssertNull();
            jackeline.Mother.AssertNull();
            jackeline.Sisters.AssertEmpty();
            jackeline.Brothers.AssertEmpty();
            jackeline.Aunts.AssertEmpty();
            jackeline.Uncles.AssertEmpty();
            jackeline.Daughters.AssertContainsOnly(marge, patty, selma);
            jackeline.Sons.AssertEmpty();
            //herb
            herb.Wife.AssertNull();
            Assert.AreEqual(abraham, herb.Father);
            Assert.AreEqual(mona, herb.Mother);
            herb.Brothers.AssertContainsOnly(homer);
            herb.Sisters.AssertEmpty();
            herb.Aunts.AssertEmpty();
            herb.Uncles.AssertEmpty();
            herb.Daughters.AssertEmpty();
            herb.Sons.AssertEmpty();
            //homer
            Assert.AreEqual(marge, homer.Wife);
            Assert.AreEqual(abraham, homer.Father);
            Assert.AreEqual(mona, homer.Mother);
            homer.Brothers.AssertContainsOnly(herb);
            homer.Sisters.AssertEmpty();
            homer.Aunts.AssertEmpty();
            homer.Uncles.AssertEmpty();
            homer.Sons.AssertContainsOnly(bart);
            homer.Daughters.AssertContainsOnly(lisa, maggie);
            //marge
            Assert.AreEqual(homer, marge.Husband);
            Assert.AreEqual(clancy, marge.Father);
            Assert.AreEqual(jackeline, marge.Mother);
            marge.Brothers.AssertEmpty();
            marge.Sisters.AssertContainsOnly(patty, selma);
            marge.Aunts.AssertEmpty();
            marge.Uncles.AssertEmpty();
            marge.Sons.AssertContainsOnly(bart);
            marge.Daughters.AssertContainsOnly(lisa, maggie);
            //patty
            patty.Husband.AssertNull();
            Assert.AreEqual(clancy, patty.Father);
            Assert.AreEqual(jackeline, patty.Mother);
            patty.Sisters.AssertContainsOnly(marge, selma);
            patty.Brothers.AssertEmpty();
            patty.Aunts.AssertEmpty();
            patty.Uncles.AssertEmpty();
            patty.Daughters.AssertEmpty();
            patty.Sons.AssertEmpty();
            //selma
            selma.Husband.AssertNull();
            Assert.AreEqual(clancy, selma.Father);
            Assert.AreEqual(jackeline, selma.Mother);
            selma.Sisters.AssertContainsOnly(marge, patty);
            selma.Brothers.AssertEmpty();
            selma.Aunts.AssertEmpty();
            selma.Uncles.AssertEmpty();
            selma.Sons.AssertEmpty();
            selma.Daughters.AssertContainsOnly(ling);
            //bart
            bart.Wife.AssertNull();
            Assert.AreEqual(homer, bart.Father);
            Assert.AreEqual(marge, bart.Mother);
            bart.Sisters.AssertContainsOnly(lisa, maggie);
            bart.Brothers.AssertEmpty();
            bart.Uncles.AssertContainsOnly(herb);
            bart.Aunts.AssertContainsOnly(patty, selma);
            bart.Daughters.AssertEmpty();
            bart.Sons.AssertEmpty();
            //lisa
            lisa.Husband.AssertNull();
            Assert.AreEqual(homer, lisa.Father);
            Assert.AreEqual(marge, lisa.Mother);
            lisa.Sisters.AssertContainsOnly(maggie);
            lisa.Brothers.AssertContainsOnly(bart);
            lisa.Uncles.AssertContainsOnly(herb);
            lisa.Aunts.AssertContainsOnly(patty, selma);
            lisa.Daughters.AssertEmpty();
            lisa.Sons.AssertEmpty();
            //maggie
            maggie.Husband.AssertNull();
            Assert.AreEqual(homer, maggie.Father);
            Assert.AreEqual(marge, maggie.Mother);
            maggie.Sisters.AssertContainsOnly(lisa);
            maggie.Brothers.AssertContainsOnly(bart);
            maggie.Aunts.AssertContainsOnly(patty, selma);
            maggie.Uncles.AssertContainsOnly(herb);
            maggie.Sons.AssertEmpty();
            maggie.Daughters.AssertEmpty();
            //Ling
            ling.Husband.AssertNull();
            Assert.AreEqual(selma, ling.Mother);
            ling.Father.AssertNull();
            ling.Sisters.AssertEmpty();
            ling.Brothers.AssertEmpty();
            ling.Aunts.AssertContainsOnly(marge, patty);
            ling.Uncles.AssertEmpty();
            ling.Daughters.AssertEmpty();
            ling.Sons.AssertEmpty();
        }
Beispiel #5
0
 /// <summary>
 /// Creates a new trace class for the given TraceContext
 /// </summary>
 /// <param name="context">The trace class for which the trace should be generated</param>
 public TransformationContextTrace(TransformationContext context)
 {
     if (context == null) throw new ArgumentNullException("context");
     this.computationsMade = context.computationsMade;
     this.computationsByTransformationRule = context.computationsByTransformationRule;
     this.context = context;
 }