コード例 #1
0
        public void ModuleAnyMatchTest()
        {
            using (ModuleRunScope scope = new ModuleRunScope())
            {
                string[] arrTest = new string[] { "1", "2", "3", "4", "5" };
                scope.SetVariable("$Arr", arrTest);

                ModuleAnyMatch anyMatch = new ModuleAnyMatch
                {
                    BuildInstance            = false,
                    Target                   = BuildTarget.ScopeResult,
                    Type                     = typeof(System.Diagnostics.Trace).AssemblyQualifiedName,
                    ScopeIEnumerableInstance = "$Arr"
                };

                anyMatch.AddStep(new ModuleMethodCallElement
                {
                    MethodName = "WriteLine",
                    Parameters = new ModuleConstructorElement
                    {
                        Arguments = new TypeValueElement[]
                        {
                            new TypeValueElement {
                                Type = "System.String", Value = "$StepSwap"
                            }
                        }
                    }
                });
                anyMatch.AddStep(new ExpressionReturnElement());

                ConditionalElement when = new ConditionalElement();
                when.AddItem(new InstanceIsTypeConditionItem {
                    ScopeInstanceKey = "$StepSwap", CompareType = "string"
                });
                when.AddItem(new StringConditionItem
                {
                    ComparisonMode         = StringComparison.InvariantCultureIgnoreCase,
                    BooleanCompareDelegate = "XmlClrLan.ConditionalElement.StringNotEqual",
                    Logic           = LogicExpression.AND,
                    ExpressionLeft  = (StringExpressItem)"3",
                    ExpressionRight = (StringExpressItem)"$StepSwap",
                });
                anyMatch.Match = when;

                anyMatch.InvokeInScope(scope);

                if (scope.LastError != null)
                {
                    throw scope.LastError;
                }


                XmlDocument    xDoc    = anyMatch.GetXmlDoc(true);
                ModuleAnyMatch restore = xDoc.GetObject <ModuleAnyMatch>();

                Assert.AreEqual(restore.ModuleId, anyMatch.ModuleId);
            }
        }
コード例 #2
0
        public void ConditionalTest()
        {
            ConditionalElement when = new ConditionalElement();

            when.AddItem(new StringConditionItem
            {
                ExpressionLeft  = TempStrGetExpression(),
                ExpressionRight = (StringExpressItem)"1",
            });

            using (ModuleRunScope scope = new ModuleRunScope())
            {
                Assert.IsTrue(when.CanRunInScope(scope));
            }

            XmlDocument xDoc   = when.GetXmlDoc(true);
            string      xmlStr = xDoc.GetXmlDocString(true);

            Trace.Write(xmlStr);

            ConditionalElement restore = xDoc.GetObject <ConditionalElement>();
            string             xmlStr2 = restore.GetXmlDocString(true);

            Trace.Write(xmlStr2);

            Assert.AreEqual(xmlStr.XmlUtf8BOMClear(), xmlStr2.XmlUtf8BOMClear());
        }
コード例 #3
0
        ModuleBranch getBranchTest(bool sharedMoudle = false)
        {
            ModuleBranch branch = new ModuleBranch
            {
            };

            //if (sharedMoudle)
            //    branch = ModuleBranch.GetScopeSharedModule("");

            ModuleWhen myWhen = new ModuleWhen();

            ConditionalElement match = new ConditionalElement();

            match.AddItem(new StringConditionItem
            {
                ExpressionLeft         = TempStrGetExpression(),
                ComparisonMode         = StringComparison.InvariantCultureIgnoreCase,
                BooleanCompareDelegate = "XmlClrLan.ConditionalElement.StringNotEqual, XmlClrLan",
                ExpressionRight        = (StringExpressItem)"1",
            });

            myWhen.Match = match;
            myWhen.AddStep(new ModuleMethodCallElement
            {
                MethodName = "AddMainType",
                Parameters = new ModuleConstructorElement
                {
                    Arguments = new TypeValueElement[]
                    {
                        new TypeValueElement {
                            Type = "System.Type", Value = "DBHR.WinFormUnity.TestModule2, DBHR.WinFormUnity"
                        }
                    }
                }
            });
            branch.Conditions = new ModuleWhen[] { myWhen, myWhen };

            //Else
            SubModuleBuildElement elseModule = new SubModuleBuildElement
            {
            };

            elseModule.AddStep(new ModuleMethodCallElement
            {
                MethodName = "AddDetailType",
                Parameters = new ModuleConstructorElement
                {
                    Arguments = new TypeValueElement[]
                    {
                        new TypeValueElement {
                            Type = "System.Type", Value = "DBHR.WinFormUnity.TestModule1, DBHR.WinFormUnity"
                        },
                        new TypeValueElement {
                            Type = "System.Type", Value = "DBHR.WinFormUnity.TestModule2, DBHR.WinFormUnity"
                        }
                    }
                }
            });
            branch.Else = elseModule;

            return(branch);
        }