Beispiel #1
0
        public void CountOfListAsCondition()
        {
            var program = MDKFactory.CreateProgram <Program>();
            var command = program.ParseCommand("if count of shipRoute[] > 0 wait");

            Assert.IsTrue(command is ConditionalCommand);
            ConditionalCommand conditionalCommand = (ConditionalCommand)command;

            Assert.IsTrue(conditionalCommand.Condition is ComparisonVariable);
            ComparisonVariable comparison = (ComparisonVariable)conditionalCommand.Condition;

            Assert.IsTrue(comparison.a is ListAggregateVariable);
            ListAggregateVariable listAggregate = (ListAggregateVariable)comparison.a;

            Assert.AreEqual(PropertyAggregate.COUNT, listAggregate.aggregation);
            Assert.IsTrue(listAggregate.expectedList is ListIndexVariable);
            ListIndexVariable listIndex = (ListIndexVariable)listAggregate.expectedList;

            Assert.IsTrue(listIndex.expectedList is InMemoryVariable);
            InMemoryVariable listVariable = (InMemoryVariable)listIndex.expectedList;

            Assert.AreEqual("shipRoute", listVariable.variableName);
            Assert.IsTrue(comparison.b is StaticVariable);
            StaticVariable comparisonVariable = (StaticVariable)comparison.b;

            Assert.AreEqual(0f, comparisonVariable.GetValue().GetValue());
        }
Beispiel #2
0
        public void AssignVariableToBasicStaticList()
        {
            var program = MDKFactory.CreateProgram <Program>();
            var command = program.ParseCommand("assign myList to [\"one\", \"two\", \"three\"]");

            Assert.IsTrue(command is VariableAssignmentCommand);
            VariableAssignmentCommand assignmentCommand = (VariableAssignmentCommand)command;

            Assert.AreEqual("myList", assignmentCommand.variableName);
            Assert.IsTrue(assignmentCommand.variable is ListIndexVariable);
            ListIndexVariable listIndex = (ListIndexVariable)assignmentCommand.variable;
            Primitive         list      = listIndex.expectedList.GetValue();

            Assert.AreEqual(Return.LIST, list.GetPrimitiveType());
            List <Variable> listItems = CastList(list).GetTypedValue().GetValues();

            Assert.AreEqual(3, listItems.Count);
            Assert.AreEqual("one", CastString(listItems[0].GetValue()).GetTypedValue());
            Assert.AreEqual("two", CastString(listItems[1].GetValue()).GetTypedValue());
            Assert.AreEqual("three", CastString(listItems[2].GetValue()).GetTypedValue());
        }
 public ListVariableAssignmentCommand(ListIndexVariable list, Variable value, bool useReference)
 {
     this.list         = list;
     this.value        = value;
     this.useReference = useReference;
 }