예제 #1
0
        public void testStartRunRuleItemLinkedToDebugItem()
        {
            rule targetRule = new rule();
            ruleItemBase startItem = targetRule.addRuleItem(new ruleItemInfo(typeof(ruleItem_startRun)));
            ruleItemBase debugItem = targetRule.addRuleItem(new ruleItemInfo(typeof(ruleItem_debug)));

            lineChain newChain = new lineChain();
            startItem.pinInfo["StartOfSim"].connectTo(newChain.serial, debugItem.pinInfo["input"]);
            targetRule.AddLineChainToGlobalPool(newChain);

            targetRule.start();
            Assert.AreEqual(false, startItem.pinInfo["StartOfSim"].value.data);
            Assert.AreEqual(tristate.noValue, debugItem.pinInfo["input"].value.data);
            targetRule.advanceDelta();
            Assert.AreEqual(true, startItem.pinInfo["StartOfSim"].value.data);
            Assert.AreEqual(tristate.yes, debugItem.pinInfo["input"].value.data);
            targetRule.advanceDelta();
            Assert.AreEqual(false, startItem.pinInfo["StartOfSim"].value.data);
            Assert.AreEqual(tristate.no, debugItem.pinInfo["input"].value.data);
            targetRule.stop();
        }
예제 #2
0
        public void testSerialisationOfRuleWithTwoRuleItemWithPinsConnected()
        {
            rule rule = new rule("test");
            lineChain line = new lineChain();

            ruleItemInfo myInfo = new ruleItemInfo();
            myInfo.itemType = ruleItemType.RuleItem;
            myInfo.ruleItemBaseType = typeof(ruleItem_and);
            ruleItemBase andItem = rule.addRuleItem(myInfo);
            ruleItemGuid andGuid = andItem.serial;

            ruleItemInfo myInfo2 = new ruleItemInfo();
            myInfo2.itemType = ruleItemType.RuleItem;
            myInfo2.ruleItemBaseType = typeof(ruleItem_desktopMessage);
            ruleItemBase messageItem = rule.addRuleItem(myInfo2);
            ruleItemGuid messageGuid = messageItem.serial;

            messageItem.pinInfo["trigger"].parentRuleItem = messageGuid;
            messageItem.pinInfo["trigger"].connectTo(line.serial,andItem.pinInfo["output1"]);
            andItem.pinInfo["output1"].connectTo(line.serial, messageItem.pinInfo["trigger"]);
            andItem.pinInfo["output1"].parentRuleItem = andGuid;
            rule.AddLineChainToGlobalPool(line);

            String serialised = rule.serialise();

            rule = rule.deserialise(serialised);

            Assert.AreEqual("test", rule.name);
            Assert.AreEqual(1, rule.lineChainCount);
            Assert.AreEqual(2, rule.ruleItems.Count);
            andItem = rule.ruleItems[andGuid.id.ToString()];
            messageItem = rule.ruleItems[messageGuid.id.ToString()];
            Assert.IsInstanceOfType(andItem, typeof(ruleItem_and));
            Assert.IsInstanceOfType(messageItem, typeof(ruleItem_desktopMessage));
            Assert.AreEqual(1, messageItem.pinInfo.Count);
            Assert.AreEqual(3, andItem.pinInfo.Count);
            Assert.AreEqual(line.serial.id.ToString(), messageItem.pinInfo["trigger"].parentLineChain.id.ToString());
            Assert.AreEqual(line.serial.id.ToString(), andItem.pinInfo["output1"].parentLineChain.id.ToString());
            Assert.AreEqual(andItem.pinInfo["output1"].serial.id.ToString(), messageItem.pinInfo["trigger"].linkedTo.id.ToString());
            Assert.AreEqual(messageItem.pinInfo["trigger"].serial.id.ToString(), andItem.pinInfo["output1"].linkedTo.id.ToString());
            Assert.AreEqual(typeof(pinDataBool), andItem.pinInfo["output1"].valueType);
            Assert.AreEqual(typeof(pinDataBool), messageItem.pinInfo["trigger"].valueType) ;
        }