public override void Execute(Context context) { _request = RequestBody.Load(context); context.LogXmlData("Request", _request, true); if (HasResponse) { _response = CallWebMethod( _request, ServiceUrl, Action, Username, Password, context); var responseForPostProcessing = SubSteps.Aggregate(_response, (current, subStep) => subStep.Execute(current, context)); } else { CallVoidWebMethod( _request, ServiceUrl, Action, Username, Password, context); } }
/// <summary> /// ITestStep.Execute() implementation /// </summary> /// <param name='context'>The context for the test, this holds state that is passed beteen tests</param> public override void Execute(Context context) { var mapType = ObjectCreator.GetType(MapTypeName, MapAssemblyPath); var destDir = Path.GetDirectoryName(Destination); if ((destDir.Length > 0) && !Directory.Exists(destDir)) { Directory.CreateDirectory(destDir); } var bmt = new BizTalkMapTester(mapType); bmt.Execute(Source, Destination); using (var fs = new FileStream(Destination, FileMode.Open, FileAccess.Read)) { using (var data = StreamHelper.LoadMemoryStream(fs)) { data.Seek(0, SeekOrigin.Begin); SubSteps.Aggregate(data, (current, subStep) => subStep.Execute(current, context)); } } }
/// <summary> /// TestStepBase.Execute() implementation /// </summary> /// <param name='context'>The context for the test, this holds state that is passed beteen tests</param> public override void Execute(Context context) { var fi = new FileInfo(RuleStoreName); if (!fi.Exists) { throw new FileNotFoundException("RuleStoreName", RuleStoreName); } var ruleStore = new FileRuleStore(fi.FullName); var rsInfo = ruleStore.GetRuleSets(RuleSetInfoCollectionName, RuleStore.Filter.Latest); if (rsInfo.Count != 1) { // oops ... error throw new InvalidOperationException(string.Format("RuleStore {0} did not contain RuleSet {1}", RuleStoreName, RuleSetInfoCollectionName)); } var ruleset = ruleStore.GetRuleSet(rsInfo[0]); // load the facts into array var facts = new List <object>(FactsList.Count); // Create an instance of the Policy Tester class using (var policyTester = new PolicyTester(ruleset)) { foreach (var currentFact in FactsList) { switch (currentFact.GetType().ToString()) { case "ObjectFact": { var fact = currentFact as ObjectFact; object[] objectArgs = null; if (null != fact.Args) { objectArgs = fact.Args.Split(',').Cast <object>().ToArray(); } Type type; if (fact.AssemblyPath.Length > 0) { var asm = Assembly.Load(fact.AssemblyPath); if (asm == null) { // fail throw (new InvalidOperationException("failed to create type " + fact.Type)); } type = asm.GetType(fact.Type, true, false); } else { // must be in path type = Type.GetType(fact.Type); } facts.Add(Activator.CreateInstance(type, objectArgs)); break; } case "DocumentFact": { var fact = currentFact as DocumentFact; var xd1 = new XmlDocument(); xd1.Load(fact.InstanceDocument); var txd = new TypedXmlDocument(fact.SchemaType, xd1); facts.Add(txd); break; } case "DataConnectionFact": { var fact = currentFact as DataConnectionFact; var conn = new SqlConnection(fact.ConnectionString); conn.Open(); var dc = new DataConnection(fact.Dataset, fact.TableName, conn); facts.Add(dc); break; } case "dataTable": case "dataRow": { var fact = currentFact as DataTableFact; var conn = new SqlConnection(fact.ConnectionString); conn.Open(); var myCommand = new SqlCommand(fact.Command, conn) { CommandType = CommandType.Text }; var dAdapt = new SqlDataAdapter(); dAdapt.TableMappings.Add("Table", fact.TableName); dAdapt.SelectCommand = myCommand; var ds = new DataSet(fact.Dataset); dAdapt.Fill(ds); var tdt = new TypedDataTable(ds.Tables[fact.TableName]); if (fact.Type == "dataRow") { var tdr = new TypedDataRow(ds.Tables[fact.TableName].Rows[0], tdt); facts.Add(tdr); } else { facts.Add(tdt); } break; } } } // Create an instance of the DebugTrackingInterceptor using (var dti = new DebugTrackingInterceptor(DebugTracking)) { // Execute Policy Tester try { policyTester.Execute(facts.ToArray(), dti); } catch (Exception e) { context.LogException(e); throw; } } } // write out all document instances passed in foreach (var fact in facts) { switch (fact.GetType().Name) { case "TypedXmlDocument": { var txd = (TypedXmlDocument)fact; context.LogData("TypedXmlDocument result: ", txd.Document.OuterXml); using (var data = StreamHelper.LoadMemoryStream(txd.Document.OuterXml)) { if (txd.DocumentType == "UBS.CLAS.PoC.Schemas.INSERTS") { SubSteps.Aggregate(data, (current, subStep) => subStep.Execute(current, context)); } } break; } case "DataConnection": { var dc = (DataConnection)fact; dc.Update(); // persist any changes break; } case "TypedDataTable": { var tdt = (TypedDataTable)fact; tdt.DataTable.AcceptChanges(); break; } case "TypedDataRow": { var tdr = (TypedDataRow)fact; tdr.DataRow.AcceptChanges(); break; } } } }