public void ModuleBranchTest() { BaseEditCalenderForm frm = new BaseEditCalenderForm(); ModuleBranch branch = getBranchTest(); //using (ModuleRunScope scope = new ModuleRunScope()) //{ // branch.InvokeInScope(frm.GetType(), frm, scope); //} string xmlStr = branch.GetXmlDocString(true); ModuleBranch restore = branch.GetXmlDoc(true).GetObject <ModuleBranch>(); Assert.AreEqual(restore.Conditions.Length, branch.Conditions.Length); }
public void CompositeModuleBuildTest() { SubModuleBuildElement wholeModule = new SubModuleBuildElement { BuildInstance = true, ModuleId = "KQ0430", Target = BuildTarget.Instance, Type = typeof(DBHR.ClientModule.BaseEditCalenderForm).GetNoVersionTypeName() }; ModuleBranch branch = getBranchTest(); #region 修正作为子集的数据设置 branch.Else.BuildInstance = false; branch.Else.ModuleId = null; branch.Else.Type = typeof(ModuleBuildStepElement).GetNoVersionTypeName(); branch.Else.Target = BuildTarget.ScopeResult; #endregion wholeModule.AddStep(branch); wholeModule.AddStep(new ModuleMethodCallElement { MethodName = "SetCalenderObjType", Parameters = new ModuleConstructorElement { Arguments = new TypeValueElement[] { new TypeValueElement { Type = "System.Type", Value = "DBHR.WinFormUnity.TestModule1, DBHR.WinFormUnity" } } } }); wholeModule.AddStep(new ModuleMethodCallElement { MethodName = "DoCreateFormControls" }); wholeModule.AddStep(new ModulePropertyElement { Name = "MdiParent", Value = "$mainForm" }); wholeModule.AddStep(new ModuleMethodCallElement { MethodName = "Show" }); string xmlStr = wholeModule.GetXmlDocString(true); SubModuleBuildElement restore = wholeModule.GetXmlDoc(true).GetObject <SubModuleBuildElement>(); Assert.AreEqual(restore.ModuleId, wholeModule.ModuleId); using (Form container = new Form1()) { using (ModuleRunScope scope = new ModuleRunScope()) { scope.SetVariable("mainForm", container); wholeModule.InvokeInScope(scope); if (scope.LastError != null) { throw scope.LastError; } } } }
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); }