Esempio n. 1
0
        public static CTsGenericInstr getTsEquivFromInstr(CInstruction inst)
        {
            string typeOfStep = inst.GetType().ToString();
            logger.Debug(String.Format("Found instruction [type={0}]", typeOfStep));

            CTsGenericInstr instr = null;

            if (String.Equals(typeOfStep, typeof(CInstrPopup).FullName))
                instr = new CTsPopup(inst.data.ToString());

            if (String.Equals(typeOfStep, typeof(CInstrWait).FullName))
                instr = new CTsWait(Convert.ToInt32(inst.data));

            if (instr == null)
                instr = basicOperatorAnalyser(inst);

            if (instr != null)
            {
                instr.Skipped = inst.Skipped;
                instr.ForceFailed = inst.ForceFailed;
                instr.ForcePassed = inst.ForcePassed;
                return instr;
            }

            throw new NotImplementedException(String.Format("Data not handled : [{0}, {1}]", typeOfStep, inst.data.GetType().ToString()));
        }
Esempio n. 2
0
        private static CTsGenericInstr basicOperatorAnalyser(CInstruction inst)
        {
            if (!isInitialized())
                throw new NullReferenceException("CTsInstrFactory needs to be configured before use.");

            CTsVariable variable = translateLocation((CVariable)inst.data);

            if (String.Equals(variable.GetType().FullName, typeof(CTsCbVariable).FullName))
            {
                return buildCbStep(inst, variable);
            }
            else if (String.Equals(variable.GetType().FullName, typeof(CTsTtVariable).FullName))
            {
                return buildTtStep(inst, variable);
            }
            else
            {
                return null;
            }
        }
Esempio n. 3
0
        private static CTsGenericInstr buildTtStep(CInstruction inst, CTsVariable TsVariable)
        {
            CTsGenericInstr instr = null;
            string typeOfStep = inst.GetType().ToString();
            string typeOfData = inst.data.GetType().ToString();
            CVariable variable = (CVariable)inst.data;

            if (String.Equals(typeOfStep, typeof(CInstrUnforce).FullName) && !String.Equals(typeOfData, typeof(CVariableArray).FullName))
            {
                return new CTsTtUnforce(TsVariable);
            }

            if (String.Equals(typeOfStep, typeof(CInstrForce).FullName))
            {
                return new CTsTtForce(TsVariable);
            }

            if (String.Equals(typeOfStep, typeof(CInstrTest).FullName))
            {
                return new CTsTtTest(TsVariable);
            }

            return instr;
        }
Esempio n. 4
0
        private static CTsGenericInstr buildCbStep(CInstruction inst, CTsVariable TsVariable)
        {
            CTsGenericInstr instr = null;
            string typeOfStep = inst.GetType().ToString();
            string typeOfData = inst.data.GetType().ToString();
            CVariable variable = (CVariable)inst.data;

            if (String.Equals(typeOfStep, typeof(CInstrUnforce).FullName))
            {
                if(String.Equals(typeOfData, typeof(CVariableArray).FullName))
                    instr = new CTsUnforceArray(TsVariable);
                else
                    instr = new CTsUnforce(TsVariable);
            }

            if (String.Equals(typeOfStep, typeof(CInstrForce).FullName))
            {
                if (String.Equals(typeOfData, typeof(CVariableBool).FullName) || String.Equals(typeOfData, typeof(CVariableInt).FullName) || String.Equals(typeOfData, typeof(CVariableUInt).FullName) || String.Equals(typeOfData, typeof(CVariableDouble).FullName))
                    instr = new CTsForce(TsVariable);

                if (String.Equals(typeOfData, typeof(CVariableArray).FullName))
                    instr = new CTsForceArray(TsVariable);
            }

            if (String.Equals(typeOfStep, typeof(CInstrTest).FullName))
            {
                if (String.Equals(typeOfData, typeof(CVariableBool).FullName) || String.Equals(typeOfData, typeof(CVariableInt).FullName) || String.Equals(typeOfData, typeof(CVariableUInt).FullName))
                    instr = new CTsTest(TsVariable);

                if (String.Equals(typeOfData, typeof(CVariableDouble).FullName))
                    instr = new CTsTestAna(TsVariable);

                if (String.Equals(typeOfData, typeof(CVariableArray).FullName))
                    instr = new CTsTestArray(TsVariable);
            }
            return instr;
        }