Esempio n. 1
0
        public void AssignSumOfBlocksWithProperty()
        {
            var program = MDKFactory.CreateProgram <Program>();
            var command = program.ParseCommand("assign \"a\" to sum of the \"forward guns\" range");

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

            Assert.IsTrue(assignCommand.variable is AggregatePropertyVariable);
            AggregatePropertyVariable aggregate = (AggregatePropertyVariable)assignCommand.variable;

            Assert.AreEqual(PropertyAggregate.SUM, aggregate.aggregationType);
        }
Esempio n. 2
0
        public void AssignAvgOfBlocksWithSelectorFirst()
        {
            var program = MDKFactory.CreateProgram <Program>();
            var command = program.ParseCommand("assign \"a\" to \"forward guns\" average range");

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

            Assert.IsTrue(assignCommand.variable is AggregatePropertyVariable);
            AggregatePropertyVariable aggregate = (AggregatePropertyVariable)assignCommand.variable;

            Assert.AreEqual(PropertyAggregate.AVG, aggregate.aggregationType);
        }
        public void MySelector()
        {
            var program = MDKFactory.CreateProgram <Program>();
            var command = program.ParseCommand("assign a to my average location");

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

            Assert.IsTrue(assignCommand.variable is AggregatePropertyVariable);
            AggregatePropertyVariable variable = (AggregatePropertyVariable)assignCommand.variable;

            Assert.IsTrue(variable.entityProvider is SelfEntityProvider);
            Assert.AreEqual(Block.PROGRAM, variable.entityProvider.GetBlockType());
        }
Esempio n. 4
0
        public void AssignAvgOfBlocksUsingImplicitAggregateAndImplicitSelector()
        {
            var program = MDKFactory.CreateProgram <Program>();
            var command = program.ParseCommand("assign \"a\" to the gun range");

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

            Assert.IsTrue(assignCommand.variable is AggregatePropertyVariable);
            AggregatePropertyVariable aggregate = (AggregatePropertyVariable)assignCommand.variable;

            Assert.AreEqual(PropertyAggregate.VALUE, aggregate.aggregationType);
            Assert.IsTrue(aggregate.entityProvider is AllEntityProvider);
            Assert.AreEqual(Block.GUN, aggregate.entityProvider.GetBlockType());
        }
Esempio n. 5
0
        public void AssignSumOfBlocksWithVariableProperty()
        {
            var program = MDKFactory.CreateProgram <Program>();
            var command = program.ParseCommand("assign \"a\" to sum of the \"cargo containers\" \"gold ingot\" amount");

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

            Assert.IsTrue(assignCommand.variable is AggregatePropertyVariable);
            AggregatePropertyVariable aggregate = (AggregatePropertyVariable)assignCommand.variable;

            Assert.AreEqual(PropertyAggregate.SUM, aggregate.aggregationType);
            Assert.AreEqual(ValueProperty.AMOUNT + "", aggregate.property.propertyType());
            Assert.AreEqual("gold ingot", aggregate.property.valueAttribute.GetValue().GetValue());
        }
Esempio n. 6
0
        public void AssignAvgOfBlocksUsingImplicitAggregateAndMySelector()
        {
            var program = MDKFactory.CreateProgram <Program>();
            var command = program.ParseCommand("assign \"a\" to my location");

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

            Assert.IsTrue(assignCommand.variable is AggregatePropertyVariable);
            AggregatePropertyVariable aggregate = (AggregatePropertyVariable)assignCommand.variable;

            Assert.AreEqual(PropertyAggregate.VALUE, aggregate.aggregationType);
            Assert.AreEqual(Property.POSITION + "", aggregate.property.propertyType());
            Assert.IsTrue(aggregate.entityProvider is SelfEntityProvider);
            Assert.AreEqual(Block.PROGRAM, aggregate.entityProvider.GetBlockType());
        }