public void LastBlockTypeImpliedIsUsed()
        {
            var command = ParseCommand("turn on the \"Boom Door Program\"");

            Assert.IsTrue(command is BlockCommand);
            BlockCommand bc = (BlockCommand)command;

            Assert.IsTrue(bc.entityProvider is SelectorEntityProvider);
            SelectorEntityProvider sep = (SelectorEntityProvider)bc.entityProvider;

            Assert.AreEqual(BlockType.PROGRAM, sep.GetBlockType());
        }
        public void BasicSelector()
        {
            var command = ParseCommand("recharge the \"batteries\"");

            Assert.IsTrue(command is BlockCommand);
            BlockCommand bc = (BlockCommand)command;

            Assert.IsTrue(bc.entityProvider is SelectorEntityProvider);
            SelectorEntityProvider sep = (SelectorEntityProvider)bc.entityProvider;

            Assert.AreEqual(BlockType.BATTERY, sep.GetBlockType());
            Assert.IsTrue(sep.isGroup);
            Assert.IsTrue(sep.selector is StaticVariable);
            Assert.AreEqual("batteries", CastString(sep.selector.GetValue()).GetStringValue());
        }
        public void VariableSelector()
        {
            var command = ParseCommand("turn on the [a] sirens");

            Assert.IsTrue(command is BlockCommand);
            BlockCommand bc = (BlockCommand)command;

            Assert.IsTrue(bc.entityProvider is SelectorEntityProvider);
            SelectorEntityProvider sep = (SelectorEntityProvider)bc.entityProvider;

            Assert.IsTrue(sep.selector is InMemoryVariable);
            InMemoryVariable variable = (InMemoryVariable)sep.selector;

            Assert.AreEqual("a", variable.variableName);
            Assert.AreEqual(BlockType.SOUND, sep.blockType);
        }
        public void ImplicitVariableSelector()
        {
            var program = MDKFactory.CreateProgram <Program>();
            var command = program.ParseCommand("turn on the $a");

            Assert.IsTrue(command is BlockCommand);
            BlockCommand bc = (BlockCommand)command;

            Assert.IsTrue(bc.entityProvider is SelectorEntityProvider);
            SelectorEntityProvider sep = (SelectorEntityProvider)bc.entityProvider;

            Assert.IsTrue(sep.selector is InMemoryVariable);
            InMemoryVariable variable = (InMemoryVariable)sep.selector;

            Assert.AreEqual("a", variable.variableName);
        }
        public void SimpleTake()
        {
            var program = MDKFactory.CreateProgram <Program>();
            var command = program.ParseCommand("take \"gold ingot\" from \"source cargo\" to \"destination cargo\"");

            Assert.IsTrue(command is TransferItemCommand);
            TransferItemCommand transferCommand = (TransferItemCommand)command;

            Assert.IsTrue(transferCommand.from is SelectorEntityProvider);
            Assert.IsTrue(transferCommand.to is SelectorEntityProvider);
            SelectorEntityProvider from = (SelectorEntityProvider)transferCommand.from;
            SelectorEntityProvider to   = (SelectorEntityProvider)transferCommand.to;

            Assert.AreEqual("source cargo", from.selector.GetValue().GetValue());
            Assert.AreEqual("destination cargo", to.selector.GetValue().GetValue());
            Assert.AreEqual("gold ingot", transferCommand.first.GetValue().GetValue());
            Assert.IsNull(transferCommand.second);
        }
        public void VariableSelectorWithIndex()
        {
            var program = MDKFactory.CreateProgram <Program>();
            var command = program.ParseCommand("turn on the $mySirens[0]");

            Assert.IsTrue(command is BlockCommand);
            BlockCommand bc = (BlockCommand)command;

            Assert.IsTrue(bc.entityProvider is IndexEntityProvider);
            IndexEntityProvider iep         = (IndexEntityProvider)bc.entityProvider;
            List <Variable>     listIndexes = CastList(iep.index.GetValue()).GetTypedValue().GetValues();

            Assert.AreEqual(1, listIndexes.Count);
            Assert.AreEqual(0f, listIndexes[0].GetValue().GetValue());
            Assert.IsTrue(iep.provider is SelectorEntityProvider);
            SelectorEntityProvider variableSelector = (SelectorEntityProvider)iep.provider;

            Assert.IsTrue(variableSelector.selector is InMemoryVariable);
            InMemoryVariable variable = (InMemoryVariable)variableSelector.selector;
        }