public void SimpleBooleanCondition() { var command = ParseCommand("if true set the \"rotors\" height to 5"); Assert.IsTrue(command is ConditionalCommand); ConditionalCommand conditionalCommand = (ConditionalCommand)command; Assert.IsTrue(conditionalCommand.Condition is StaticVariable); StaticVariable variable = (StaticVariable)conditionalCommand.Condition; Assert.IsTrue(variable.GetValue() is BooleanPrimitive); BooleanPrimitive boolean = (BooleanPrimitive)variable.GetValue(); Assert.IsTrue(boolean.GetBooleanValue()); }
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()); }
public void SimpleBooleanCondition() { var program = MDKFactory.CreateProgram <Program>(); var command = program.ParseCommand("if true set the \"rotors\" height to 5"); Assert.IsTrue(command is ConditionalCommand); ConditionalCommand conditionalCommand = (ConditionalCommand)command; Assert.IsTrue(conditionalCommand.Condition is StaticVariable); StaticVariable variable = (StaticVariable)conditionalCommand.Condition; Assert.IsTrue(variable.GetValue() is BooleanPrimitive); BooleanPrimitive boolean = (BooleanPrimitive)variable.GetValue(); Assert.IsTrue(boolean.GetTypedValue()); }
public void ParseVectorFromGPSCoordinate() { var program = MDKFactory.CreateProgram <Program>(); var command = program.ParseCommand("assign a to \"GPS:surface:53573.9750085028:-26601.8512032533:12058.8229348438:#FF75C9F1:\""); Assert.IsTrue(command is VariableAssignmentCommand); VariableAssignmentCommand assignCommand = (VariableAssignmentCommand)command; Assert.IsTrue(assignCommand.variable is StaticVariable); StaticVariable variable = (StaticVariable)assignCommand.variable; Assert.IsTrue(variable.GetValue() is VectorPrimitive); Vector3D vector = CastVector(variable.GetValue()).GetTypedValue(); Assert.AreEqual(53573.9750085028, vector.X); Assert.AreEqual(-26601.8512032533, vector.Y); Assert.AreEqual(12058.8229348438, vector.Z); }