// ReSharper disable InconsistentNaming public void ActivityDataMappingBuilder_SetupActivityData_WhenValidInputOutputMappingAndNoServiceDef_ExpectValidInputsAndOutputs() { //------------Setup for test-------------------------- #region ServiceDef const string inputString = @"<Inputs><Input Name=""Rows"" Source=""Rows"" EmptyToNull=""false"" DefaultValue="""" /></Inputs>"; const string outputString = @"<Outputs><Output Name=""BigID"" MapsTo=""BigID"" Value=""[[Row().BigID]]"" Recordset=""Row"" /><Output Name=""Column1"" MapsTo=""Column1"" Value=""[[Row().Column1]]"" Recordset=""Row"" /><Output Name=""Column2"" MapsTo=""Column2"" Value=""[[Row().Column2]]"" Recordset=""Row"" /><Output Name=""Column3"" MapsTo=""Column3"" Value=""[[Row().Column3]]"" Recordset=""Row"" /><Output Name=""Column4"" MapsTo=""Column4"" Value=""[[Row().Column4]]"" Recordset=""Row"" /><Output Name=""Column5"" MapsTo=""Column5"" Value=""[[Row().Column5]]"" Recordset=""Row"" /><Output Name=""Column6"" MapsTo=""Column6"" Value=""[[Row().Column6]]"" Recordset=""Row"" /><Output Name=""Column7"" MapsTo=""Column7"" Value=""[[Row().Column7]]"" Recordset=""Row"" /><Output Name=""Column8"" MapsTo=""Column8"" Value=""[[Row().Column8]]"" Recordset=""Row"" /><Output Name=""Column9"" MapsTo=""Column9"" Value=""[[Row().Column9]]"" Recordset=""Row"" /><Output Name=""Column10"" MapsTo=""Column10"" Value=""[[Row().Column10]]"" Recordset=""Row"" /></Outputs>"; #endregion var activityDataMappingBuilder = new ActivityDataMappingBuilder(); Mock<IContextualResourceModel> resourceModel = new Mock<IContextualResourceModel>(); resourceModel.Setup(c => c.DataList).Returns("<DataList/>"); Mock<IWebActivity> activity = new Mock<IWebActivity>(); activity.Setup(c => c.SavedInputMapping).Returns(string.Empty); activity.Setup(c => c.SavedOutputMapping).Returns(string.Empty); activity.Setup(c => c.ResourceModel.Outputs).Returns(outputString); activity.Setup(c => c.ResourceModel.Inputs).Returns(inputString); activity.Setup(c => c.ResourceModel.WorkflowXaml).Returns(new StringBuilder()); activity.Setup(c => c.ResourceModel.ResourceType).Returns(ResourceType.Service); //------------Execute Test--------------------------- activityDataMappingBuilder.SetupActivityData(activity.Object); //------------Assert Results------------------------- const string inputExpected = @"<Inputs><Input Name=""Rows"" Source=""Rows"" EmptyToNull=""false"" DefaultValue="""" /></Inputs>"; const string outputExpected = @"<Outputs><Output Name=""BigID"" MapsTo=""BigID"" Value=""[[Row().BigID]]"" Recordset=""Row"" /><Output Name=""Column1"" MapsTo=""Column1"" Value=""[[Row().Column1]]"" Recordset=""Row"" /><Output Name=""Column2"" MapsTo=""Column2"" Value=""[[Row().Column2]]"" Recordset=""Row"" /><Output Name=""Column3"" MapsTo=""Column3"" Value=""[[Row().Column3]]"" Recordset=""Row"" /><Output Name=""Column4"" MapsTo=""Column4"" Value=""[[Row().Column4]]"" Recordset=""Row"" /><Output Name=""Column5"" MapsTo=""Column5"" Value=""[[Row().Column5]]"" Recordset=""Row"" /><Output Name=""Column6"" MapsTo=""Column6"" Value=""[[Row().Column6]]"" Recordset=""Row"" /><Output Name=""Column7"" MapsTo=""Column7"" Value=""[[Row().Column7]]"" Recordset=""Row"" /><Output Name=""Column8"" MapsTo=""Column8"" Value=""[[Row().Column8]]"" Recordset=""Row"" /><Output Name=""Column9"" MapsTo=""Column9"" Value=""[[Row().Column9]]"" Recordset=""Row"" /><Output Name=""Column10"" MapsTo=""Column10"" Value=""[[Row().Column10]]"" Recordset=""Row"" /></Outputs>"; Assert.AreEqual(inputExpected, activityDataMappingBuilder.ActivityInputDefinitions); Assert.AreEqual(outputExpected, activityDataMappingBuilder.ActivityOutputDefinitions); }
public void ActivityDataMappingBuilder_Generate_WhenValidWorkflowWithSavedMappings_ExpectSavedInputAndOutputList() { //------------Setup for test-------------------------- #region ServiceDef const string serviceDefStr = @"<Service ID=""8912e8db-074f-43e4-85ea-9376162d3332"" Version=""1.0"" ServerID=""51a58300-7e9d-4927-a57b-e5d700b11b55"" Name=""fileTest"" ResourceType=""WorkflowService"" IsValid=""true""> <DisplayName>fileTest</DisplayName> <Category>Mo</Category> <IsNewWorkflow>false</IsNewWorkflow> <AuthorRoles>Domain Users,Windows SBS Remote Web Workplace Users,Windows SBS Fax Users,Windows SBS Folder Redirection Accounts,All Users,Windows SBS SharePoint_MembersGroup,Windows SBS Link Users,Company Users,Business Design Studio Developers,Test Engineers,DEV2 Limited Internet Access,</AuthorRoles> <Comment>a</Comment> <Tags></Tags> <IconPath>pack://application:,,,/Warewolf Studio;component/images/Workflow-32.png</IconPath> <HelpLink>a:/</HelpLink> <UnitTestTargetWorkflowService></UnitTestTargetWorkflowService> <DataList> <result Description="""" IsEditable=""True"" ColumnIODirection=""Output"" /> <recset1 Description="""" IsEditable=""True"" ColumnIODirection=""None""> <f1 Description="""" IsEditable=""True"" ColumnIODirection=""None"" /> </recset1> <recset2 Description="""" IsEditable=""True"" ColumnIODirection=""None""> <f2 Description="""" IsEditable=""True"" ColumnIODirection=""None"" /> </recset2> </DataList> <Action Name=""InvokeWorkflow"" Type=""Workflow""> <XamlDefinition><Activity x:Class=""fileTest"" xmlns=""http://schemas.microsoft.com/netfx/2009/xaml/activities"" xmlns:av=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" xmlns:dc=""clr-namespace:Dev2.Common;assembly=Dev2.Common"" xmlns:ddc=""clr-namespace:Dev2.DataList.Contract;assembly=Dev2.Data"" xmlns:ddcb=""clr-namespace:Dev2.DataList.Contract.Binary_Objects;assembly=Dev2.Data"" xmlns:ddd=""clr-namespace:Dev2.Data.Decision;assembly=Dev2.Data"" xmlns:dddo=""clr-namespace:Dev2.Data.Decisions.Operations;assembly=Dev2.Data"" xmlns:ddsm=""clr-namespace:Dev2.Data.SystemTemplates.Models;assembly=Dev2.Data"" xmlns:dpe=""clr-namespace:Dev2.Providers.Errors;assembly=Dev2.Infrastructure"" xmlns:mva=""clr-namespace:Microsoft.VisualBasic.Activities;assembly=System.Activities"" xmlns:s=""clr-namespace:System;assembly=mscorlib"" xmlns:sads=""http://schemas.microsoft.com/netfx/2010/xaml/activities/debugger"" xmlns:sap=""http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation"" xmlns:scg=""clr-namespace:System.Collections.Generic;assembly=mscorlib"" xmlns:sco=""clr-namespace:System.Collections.ObjectModel;assembly=mscorlib"" xmlns:uaba=""clr-namespace:Unlimited.Applications.BusinessDesignStudio.Activities;assembly=Dev2.Activities"" xmlns:uf=""clr-namespace:Unlimited.Framework;assembly=Dev2.Core"" xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml""><x:Members><x:Property Name=""AmbientDataList"" Type=""InOutArgument(scg:List(x:String))"" /><x:Property Name=""ParentWorkflowInstanceId"" Type=""InOutArgument(s:Guid)"" /><x:Property Name=""ParentServiceName"" Type=""InOutArgument(x:String)"" /></x:Members><sap:VirtualizedContainerService.HintSize>719,676</sap:VirtualizedContainerService.HintSize><mva:VisualBasic.Settings>Assembly references and imported namespaces serialized as XML namespaces</mva:VisualBasic.Settings><TextExpression.NamespacesForImplementation><scg:List x:TypeArguments=""x:String"" Capacity=""7""><x:String>Dev2.Common</x:String><x:String>Dev2.Data.Decisions.Operations</x:String><x:String>Dev2.Data.SystemTemplates.Models</x:String><x:String>Dev2.DataList.Contract</x:String><x:String>Dev2.DataList.Contract.Binary_Objects</x:String><x:String>Unlimited.Framework</x:String><x:String>Unlimited.Applications.BusinessDesignStudio.Activities</x:String></scg:List></TextExpression.NamespacesForImplementation><TextExpression.ReferencesForImplementation><sco:Collection x:TypeArguments=""AssemblyReference""><AssemblyReference>Dev2.Common</AssemblyReference><AssemblyReference>Dev2.Data</AssemblyReference><AssemblyReference>Dev2.Core</AssemblyReference><AssemblyReference>Dev2.Activities</AssemblyReference></sco:Collection></TextExpression.ReferencesForImplementation><Flowchart DisplayName=""fileTest"" sap:VirtualizedContainerService.HintSize=""679,636"" mva:VisualBasic.Settings=""Assembly references and imported namespaces serialized as XML namespaces""><Flowchart.Variables><Variable x:TypeArguments=""scg:List(x:String)"" Name=""InstructionList"" /><Variable x:TypeArguments=""x:String"" Name=""LastResult"" /><Variable x:TypeArguments=""x:Boolean"" Name=""HasError"" /><Variable x:TypeArguments=""x:String"" Name=""ExplicitDataList"" /><Variable x:TypeArguments=""x:Boolean"" Name=""IsValid"" /><Variable x:TypeArguments=""uf:UnlimitedObject"" Name=""d"" /><Variable x:TypeArguments=""uaba:Util"" Name=""t"" /><Variable x:TypeArguments=""ddd:Dev2DataListDecisionHandler"" Name=""Dev2DecisionHandler"" /></Flowchart.Variables><sap:WorkflowViewStateService.ViewState><scg:Dictionary x:TypeArguments=""x:String, x:Object""><x:Boolean x:Key=""IsExpanded"">False</x:Boolean><av:Point x:Key=""ShapeLocation"">270,2.5</av:Point><av:Size x:Key=""ShapeSize"">60,75</av:Size><av:PointCollection x:Key=""ConnectorLocation"">300,77.5 300,133 313.395,133</av:PointCollection><x:Double x:Key=""Width"">665</x:Double></scg:Dictionary></sap:WorkflowViewStateService.ViewState><Flowchart.StartNode><x:Reference>__ReferenceID1</x:Reference></Flowchart.StartNode><FlowStep x:Name=""__ReferenceID0""><sap:WorkflowViewStateService.ViewState><scg:Dictionary x:TypeArguments=""x:String, x:Object""><av:Point x:Key=""ShapeLocation"">135,243.5</av:Point><av:Size x:Key=""ShapeSize"">264,116</av:Size></scg:Dictionary></sap:WorkflowViewStateService.ViewState><uaba:DsfDataMergeActivity Compiler=""{x:Null}"" CurrentResult=""{x:Null}"" DataObject=""{x:Null}"" ExplicitDataList=""{x:Null}"" InputMapping=""{x:Null}"" InputTransformation=""{x:Null}"" OnResumeKeepList=""{x:Null}"" OutputMapping=""{x:Null}"" ParentServiceID=""{x:Null}"" ParentServiceName=""{x:Null}"" ParentWorkflowInstanceId=""{x:Null}"" ResultTransformation=""{x:Null}"" ScenarioID=""{x:Null}"" ScopingObject=""{x:Null}"" SimulationOutput=""{x:Null}"" Add=""False"" DatabindRecursive=""False"" DisplayName=""Data Merge (1)"" HasError=""[HasError]"" sap:VirtualizedContainerService.HintSize=""264,116"" InstructionList=""[InstructionList]"" IsSimulationEnabled=""False"" IsUIStep=""False"" IsValid=""[IsValid]"" IsWorkflow=""False"" OnResumeClearAmbientDataList=""False"" OnResumeClearTags=""FormView,InstanceId,Bookmark,ParentWorkflowInstanceId,ParentServiceName,WebPage"" Result=""[[sdfsdf]]"" SimulationMode=""OnDemand"" UniqueID=""99f5593a-0f6f-4f8b-a34f-bf93190e14c6""><uaba:DsfDataMergeActivity.AmbientDataList><InOutArgument x:TypeArguments=""scg:List(x:String)"" /></uaba:DsfDataMergeActivity.AmbientDataList><uaba:DsfDataMergeActivity.MergeCollection><scg:List x:TypeArguments=""uaba:DataMergeDTO"" Capacity=""4""><uaba:DataMergeDTO Alignment=""Left"" At="""" EnableAt=""False"" IndexNumber=""1"" InputVariable=""sdsd"" Inserted=""False"" MergeType=""New Line"" Padding="""" WatermarkTextVariable=""[[Recordset().F1]]"" /><uaba:DataMergeDTO Alignment=""Left"" At="""" EnableAt=""False"" IndexNumber=""2"" InputVariable="""" Inserted=""False"" MergeType=""None"" Padding="""" WatermarkTextVariable=""[[Recordset().F2]]"" /></scg:List></uaba:DsfDataMergeActivity.MergeCollection><uaba:DsfDataMergeActivity.ParentInstanceID><InOutArgument x:TypeArguments=""x:String"" /></uaba:DsfDataMergeActivity.ParentInstanceID><sap:WorkflowViewStateService.ViewState><scg:Dictionary x:TypeArguments=""x:String, x:Object""><x:Boolean x:Key=""IsExpanded"">True</x:Boolean></scg:Dictionary></sap:WorkflowViewStateService.ViewState></uaba:DsfDataMergeActivity></FlowStep><FlowStep x:Name=""__ReferenceID1""><sap:WorkflowViewStateService.ViewState><scg:Dictionary x:TypeArguments=""x:String, x:Object""><av:Point x:Key=""ShapeLocation"">313.395,94</av:Point><av:Size x:Key=""ShapeSize"">230,78</av:Size><av:PointCollection x:Key=""ConnectorLocation"">428.395,172 428.395,301.5 399,301.5</av:PointCollection></scg:Dictionary></sap:WorkflowViewStateService.ViewState><uaba:DsfMultiAssignActivity Compiler=""{x:Null}"" CurrentResult=""{x:Null}"" DataObject=""{x:Null}"" ExplicitDataList=""{x:Null}"" InputMapping=""{x:Null}"" InputTransformation=""{x:Null}"" OnResumeKeepList=""{x:Null}"" OutputMapping=""{x:Null}"" ParentServiceID=""{x:Null}"" ParentServiceName=""{x:Null}"" ParentWorkflowInstanceId=""{x:Null}"" ResultTransformation=""{x:Null}"" ScenarioID=""{x:Null}"" ScopingObject=""{x:Null}"" ServiceHost=""{x:Null}"" SimulationOutput=""{x:Null}"" Add=""False"" CreateBookmark=""False"" DatabindRecursive=""False"" DisplayName=""Assign (6)"" HasError=""[HasError]"" sap:VirtualizedContainerService.HintSize=""230,78"" InstructionList=""[InstructionList]"" IsSimulationEnabled=""False"" IsUIStep=""False"" IsValid=""[IsValid]"" IsWorkflow=""False"" OnResumeClearAmbientDataList=""False"" OnResumeClearTags=""FormView,InstanceId,Bookmark,ParentWorkflowInstanceId,ParentServiceName,WebPage"" SimulationMode=""OnDemand"" UniqueID=""2cc98df1-da95-421d-b413-98ff091f7397"" UpdateAllOccurrences=""False""><uaba:DsfMultiAssignActivity.AmbientDataList><InOutArgument x:TypeArguments=""scg:List(x:String)"" /></uaba:DsfMultiAssignActivity.AmbientDataList><uaba:DsfMultiAssignActivity.FieldsCollection><scg:List x:TypeArguments=""uaba:ActivityDTO"" Capacity=""8""><uaba:ActivityDTO ErrorMessage=""{x:Null}"" FieldName=""[[recset1(1).f1]]"" FieldValue=""test1"" IndexNumber=""1"" Inserted=""False"" IsFieldNameFocused=""False"" WatermarkTextValue=""Value"" WatermarkTextVariable=""[[Variable1]]""><uaba:ActivityDTO.Errors><scg:Dictionary x:TypeArguments=""x:String, scg:List(dpe:IActionableErrorInfo)"" /></uaba:ActivityDTO.Errors><uaba:ActivityDTO.OutList><scg:List x:TypeArguments=""x:String"" Capacity=""0"" /></uaba:ActivityDTO.OutList></uaba:ActivityDTO><uaba:ActivityDTO ErrorMessage=""{x:Null}"" FieldName=""[[recset2(1).f2]]"" FieldValue=""test2"" IndexNumber=""2"" Inserted=""False"" IsFieldNameFocused=""False"" WatermarkTextValue=""Value"" WatermarkTextVariable=""[[Variable2]]""><uaba:ActivityDTO.Errors><scg:Dictionary x:TypeArguments=""x:String, scg:List(dpe:IActionableErrorInfo)"" /></uaba:ActivityDTO.Errors><uaba:ActivityDTO.OutList><scg:List x:TypeArguments=""x:String"" Capacity=""0"" /></uaba:ActivityDTO.OutList></uaba:ActivityDTO><uaba:ActivityDTO ErrorMessage=""{x:Null}"" FieldName=""[[recset1(2).f1]]"" FieldValue=""test3"" IndexNumber=""3"" Inserted=""False"" IsFieldNameFocused=""False"" WatermarkTextValue="""" WatermarkTextVariable=""""><uaba:ActivityDTO.Errors><scg:Dictionary x:TypeArguments=""x:String, scg:List(dpe:IActionableErrorInfo)"" /></uaba:ActivityDTO.Errors><uaba:ActivityDTO.OutList><scg:List x:TypeArguments=""x:String"" Capacity=""0"" /></uaba:ActivityDTO.OutList></uaba:ActivityDTO><uaba:ActivityDTO ErrorMessage=""{x:Null}"" FieldName=""[[recset2(2).f2]]"" FieldValue=""test4"" IndexNumber=""4"" Inserted=""False"" IsFieldNameFocused=""False"" WatermarkTextValue="""" WatermarkTextVariable=""""><uaba:ActivityDTO.Errors><scg:Dictionary x:TypeArguments=""x:String, scg:List(dpe:IActionableErrorInfo)"" /></uaba:ActivityDTO.Errors><uaba:ActivityDTO.OutList><scg:List x:TypeArguments=""x:String"" Capacity=""0"" /></uaba:ActivityDTO.OutList></uaba:ActivityDTO><uaba:ActivityDTO ErrorMessage=""{x:Null}"" FieldName=""[[recset1(3).f1]]"" FieldValue=""test5"" IndexNumber=""5"" Inserted=""False"" IsFieldNameFocused=""False"" WatermarkTextValue="""" WatermarkTextVariable=""""><uaba:ActivityDTO.Errors><scg:Dictionary x:TypeArguments=""x:String, scg:List(dpe:IActionableErrorInfo)"" /></uaba:ActivityDTO.Errors><uaba:ActivityDTO.OutList><scg:List x:TypeArguments=""x:String"" Capacity=""0"" /></uaba:ActivityDTO.OutList></uaba:ActivityDTO><uaba:ActivityDTO ErrorMessage=""{x:Null}"" FieldName=""[[recset2(3).f2]]"" FieldValue=""test6"" IndexNumber=""6"" Inserted=""False"" IsFieldNameFocused=""False"" WatermarkTextValue="""" WatermarkTextVariable=""""><uaba:ActivityDTO.Errors><scg:Dictionary x:TypeArguments=""x:String, scg:List(dpe:IActionableErrorInfo)"" /></uaba:ActivityDTO.Errors><uaba:ActivityDTO.OutList><scg:List x:TypeArguments=""x:String"" Capacity=""0"" /></uaba:ActivityDTO.OutList></uaba:ActivityDTO><uaba:ActivityDTO ErrorMessage=""{x:Null}"" FieldName="""" FieldValue="""" IndexNumber=""7"" Inserted=""False"" IsFieldNameFocused=""False"" WatermarkTextValue="""" WatermarkTextVariable=""""><uaba:ActivityDTO.Errors><scg:Dictionary x:TypeArguments=""x:String, scg:List(dpe:IActionableErrorInfo)"" /></uaba:ActivityDTO.Errors><uaba:ActivityDTO.OutList><scg:List x:TypeArguments=""x:String"" Capacity=""0"" /></uaba:ActivityDTO.OutList></uaba:ActivityDTO></scg:List></uaba:DsfMultiAssignActivity.FieldsCollection><uaba:DsfMultiAssignActivity.ParentInstanceID><InOutArgument x:TypeArguments=""x:String"" /></uaba:DsfMultiAssignActivity.ParentInstanceID><sap:WorkflowViewStateService.ViewState><scg:Dictionary x:TypeArguments=""x:String, x:Object""><x:Boolean x:Key=""IsExpanded"">True</x:Boolean></scg:Dictionary></sap:WorkflowViewStateService.ViewState></uaba:DsfMultiAssignActivity><FlowStep.Next><x:Reference>__ReferenceID0</x:Reference></FlowStep.Next></FlowStep></Flowchart></Activity></XamlDefinition> </Action> <ErrorMessages /> <Source /> <Signature xmlns=""http://www.w3.org/2000/09/xmldsig#""> <SignedInfo> <CanonicalizationMethod Algorithm=""http://www.w3.org/TR/2001/REC-xml-c14n-20010315"" /> <SignatureMethod Algorithm=""http://www.w3.org/2000/09/xmldsig#rsa-sha1"" /> <Reference URI=""""> <Transforms> <Transform Algorithm=""http://www.w3.org/2000/09/xmldsig#enveloped-signature"" /> </Transforms> <DigestMethod Algorithm=""http://www.w3.org/2000/09/xmldsig#sha1"" /> <DigestValue>VWE/gfMxoDaAnF2QgBKVXjvfTVs=</DigestValue> </Reference> </SignedInfo> <SignatureValue>bH2cevYAj3616fNuu55cKdl4pehbJN/lcqTXJPdfRXBhxrJ/iMbMRX/sU03mzycS323KU/2sEyLfQYUYOZh0EHcKD4Bchny+/I04n+PxDbtdGJe9QM561vBQZ6g6fUnQB63lh2uNneQQ8nd+sQ4JY4/C2v6CbPTmEryuFJTclUQ=</SignatureValue> </Signature> </Service>"; const string datalistFragment = @"<DataList><result Description="""" IsEditable=""True"" ColumnIODirection=""Output"" /><result2 Description="""" IsEditable=""True"" ColumnIODirection=""Output"" /><recset1 Description="""" IsEditable=""True"" ColumnIODirection=""Input"" ><f1 Description="""" IsEditable=""True"" ColumnIODirection=""Input"" /></recset1><recset2 Description="""" IsEditable=""True"" ColumnIODirection=""Input"" ><f2 Description="""" IsEditable=""True"" ColumnIODirection=""Input"" /></recset2></DataList>"; #endregion var activityDataMappingBuilder = new ActivityDataMappingBuilder(); Mock<IContextualResourceModel> resourceModel = new Mock<IContextualResourceModel>(); resourceModel.Setup(c => c.DataList).Returns("<DataList/>"); Mock<IWebActivity> activity = new Mock<IWebActivity>(); activity.Setup(c => c.SavedInputMapping).Returns(@"<Inputs><Input Name=""f1"" Source=""[[recset1(*).f1a]]"" Recordset=""recset1"" /><Input Name=""f2"" Source=""[[recset2(*).f2a]]"" Recordset=""recset2"" /></Inputs>"); activity.Setup(c => c.SavedOutputMapping).Returns(@"<Outputs><Output Name=""result"" MapsTo=""[[result]]"" Value=""[[resultValue]]"" /></Outputs>"); activity.Setup(c => c.ResourceModel.WorkflowXaml).Returns(new StringBuilder(serviceDefStr)); activity.Setup(c => c.UnderlyingWebActivityObjectType).Returns(typeof(DsfActivity)); activity.Setup(c => c.ResourceModel.DataList).Returns(datalistFragment); activityDataMappingBuilder.SetupActivityData(activity.Object); //------------Execute Test--------------------------- var result = activityDataMappingBuilder.Generate(); //------------Assert Results------------------------- // check counts first Assert.AreEqual(2, result.Inputs.Count); // now check data Assert.AreEqual("[[recset1(*).f1a]]", result.Inputs[0].MapsTo); Assert.AreEqual("[[recset2(*).f2a]]", result.Inputs[1].MapsTo); // check counts first Assert.AreEqual(2, result.Outputs.Count); // now check data Assert.AreEqual("[[resultValue]]", result.Outputs[0].Value); Assert.AreEqual("[[result2]]", result.Outputs[1].Value); }
public void ActivityDataMappingBuilder_Generate_WhenValidServiceDefintionAndActivityHasSaveMappingDataWithStaticValue_ExpectValidInputAndOutputList() { //------------Setup for test-------------------------- #region Setup Data const string outputDefStr = @" <Outputs> <Output Name=""BigID"" MapsTo=""[[BigID]]"" Value=""[[Rowz().BigIDs]]"" Recordset=""Row"" /> <Output Name=""Column1"" MapsTo=""[[Column1]]"" Value=""[[Rowz().Column1]]"" Recordset=""Row"" /> <Output Name=""Column2"" MapsTo=""[[Column2]]"" Value=""[[Rowz().Column2]]"" Recordset=""Row"" /> <Output Name=""Column3"" MapsTo=""[[Column3]]"" Value=""[[Rowz().Column3]]"" Recordset=""Row"" /> <Output Name=""Column4"" MapsTo=""[[Column4]]"" Value=""[[Rowz().Column4]]"" Recordset=""Row"" /> <Output Name=""Column5"" MapsTo=""[[Column5]]"" Value=""[[Rowz().Column5]]"" Recordset=""Row"" /> <Output Name=""Column6"" MapsTo=""[[Column6]]"" Value=""[[Rowz().Column6]]"" Recordset=""Row"" /> <Output Name=""Column7"" MapsTo=""[[Column7]]"" Value=""[[Rowz().Column7]]"" Recordset=""Row"" /> <Output Name=""Column8"" MapsTo=""[[Column8]]"" Value=""[[Rowz().Column8]]"" Recordset=""Row"" /> <Output Name=""Column9"" MapsTo=""[[Column9]]"" Value=""[[Rowz().Column9]]"" Recordset=""Row"" /> <Output Name=""Column10"" MapsTo=""[[Column10]]"" Value=""[[Rowz().Column10]]"" Recordset=""Row"" /> </Outputs>"; const string inputDefStr = @"<Inputs> <Input Name=""Rows"" Source=""5""/> </Inputs>"; const string inputString = @"<Inputs> <Input Name=""Rows"" Source=""Rows"" EmptyToNull=""false"" DefaultValue="""" /> </Inputs>"; const string outputString = @"<Outputs> <Output Name=""BigID"" MapsTo=""BigID"" Value=""[[Row().BigID]]"" Recordset=""Row"" /> <Output Name=""Column1"" MapsTo=""Column1"" Value=""[[Row().Column1]]"" Recordset=""Row"" /> <Output Name=""Column2"" MapsTo=""Column2"" Value=""[[Row().Column2]]"" Recordset=""Row"" /> <Output Name=""Column3"" MapsTo=""Column3"" Value=""[[Row().Column3]]"" Recordset=""Row"" /> <Output Name=""Column4"" MapsTo=""Column4"" Value=""[[Row().Column4]]"" Recordset=""Row"" /> <Output Name=""Column5"" MapsTo=""Column5"" Value=""[[Row().Column5]]"" Recordset=""Row"" /> <Output Name=""Column6"" MapsTo=""Column6"" Value=""[[Row().Column6]]"" Recordset=""Row"" /> <Output Name=""Column7"" MapsTo=""Column7"" Value=""[[Row().Column7]]"" Recordset=""Row"" /> <Output Name=""Column8"" MapsTo=""Column8"" Value=""[[Row().Column8]]"" Recordset=""Row"" /> <Output Name=""Column9"" MapsTo=""Column9"" Value=""[[Row().Column9]]"" Recordset=""Row"" /> <Output Name=""Column10"" MapsTo=""Column10"" Value=""[[Row().Column10]]"" Recordset=""Row"" /> </Outputs>"; #endregion var activityDataMappingBuilder = new ActivityDataMappingBuilder(); Mock<IContextualResourceModel> resourceModel = new Mock<IContextualResourceModel>(); resourceModel.Setup(c => c.DataList).Returns("<DataList/>"); Mock<IWebActivity> activity = new Mock<IWebActivity>(); activity.Setup(c => c.SavedInputMapping).Returns(inputDefStr); activity.Setup(c => c.SavedOutputMapping).Returns(outputDefStr); activity.Setup(c => c.ResourceModel.WorkflowXaml).Returns(new StringBuilder()); activity.Setup(c => c.ResourceModel.Inputs).Returns(inputString); activity.Setup(c => c.ResourceModel.Outputs).Returns(outputString); activity.Setup(c => c.UnderlyingWebActivityObjectType).Returns(typeof(DsfDatabaseActivity)); activity.Setup(c => c.ResourceModel.ResourceType).Returns(ResourceType.Service); activityDataMappingBuilder.SetupActivityData(activity.Object); //------------Execute Test--------------------------- var result = activityDataMappingBuilder.Generate(); //------------Assert Results------------------------- // check counts first Assert.AreEqual(1, result.Inputs.Count); Assert.AreEqual(11, result.Outputs.Count); // now check data Assert.AreEqual("5", result.Inputs[0].Value); Assert.AreEqual("[[Rowz().BigIDs]]", result.Outputs[0].Value); Assert.AreEqual("[[Rowz().Column1]]", result.Outputs[1].Value); Assert.AreEqual("[[Rowz().Column2]]", result.Outputs[2].Value); Assert.AreEqual("[[Rowz().Column3]]", result.Outputs[3].Value); Assert.AreEqual("[[Rowz().Column4]]", result.Outputs[4].Value); Assert.AreEqual("[[Rowz().Column5]]", result.Outputs[5].Value); Assert.AreEqual("[[Rowz().Column6]]", result.Outputs[6].Value); Assert.AreEqual("[[Rowz().Column7]]", result.Outputs[7].Value); Assert.AreEqual("[[Rowz().Column8]]", result.Outputs[8].Value); Assert.AreEqual("[[Rowz().Column9]]", result.Outputs[9].Value); Assert.AreEqual("[[Rowz().Column10]]", result.Outputs[10].Value); }
public void ActivityDataMappingBuilder_SetupActivityData_WhenValidServiceDefintion_ExpectEmptySavedIODataAndCorrectActivityType() { //------------Setup for test-------------------------- #region ServiceDef const string serviceDefStr = @" <Action Name=""Row"" Type=""InvokeStoredProc"" SourceID=""62505a00-b304-4ac0-a55c-50ce85111f16"" SourceName=""GenDev"" SourceMethod=""dbo.proc_get_Rows""> <Inputs> <Input Name=""Rows"" Source=""Rows"" EmptyToNull=""false"" DefaultValue="""" /> </Inputs> <Outputs> <Output Name=""BigID"" MapsTo=""BigID"" Value=""[[Row().BigID]]"" Recordset=""Row"" /> <Output Name=""Column1"" MapsTo=""Column1"" Value=""[[Row().Column1]]"" Recordset=""Row"" /> <Output Name=""Column2"" MapsTo=""Column2"" Value=""[[Row().Column2]]"" Recordset=""Row"" /> <Output Name=""Column3"" MapsTo=""Column3"" Value=""[[Row().Column3]]"" Recordset=""Row"" /> <Output Name=""Column4"" MapsTo=""Column4"" Value=""[[Row().Column4]]"" Recordset=""Row"" /> <Output Name=""Column5"" MapsTo=""Column5"" Value=""[[Row().Column5]]"" Recordset=""Row"" /> <Output Name=""Column6"" MapsTo=""Column6"" Value=""[[Row().Column6]]"" Recordset=""Row"" /> <Output Name=""Column7"" MapsTo=""Column7"" Value=""[[Row().Column7]]"" Recordset=""Row"" /> <Output Name=""Column8"" MapsTo=""Column8"" Value=""[[Row().Column8]]"" Recordset=""Row"" /> <Output Name=""Column9"" MapsTo=""Column9"" Value=""[[Row().Column9]]"" Recordset=""Row"" /> <Output Name=""Column10"" MapsTo=""Column10"" Value=""[[Row().Column10]]"" Recordset=""Row"" /> </Outputs> </Action>"; #endregion var activityDataMappingBuilder = new ActivityDataMappingBuilder(); Mock<IContextualResourceModel> resourceModel = new Mock<IContextualResourceModel>(); resourceModel.Setup(c => c.DataList).Returns("<DataList/>"); Mock<IWebActivity> activity = new Mock<IWebActivity>(); activity.Setup(c => c.SavedInputMapping).Returns(string.Empty); activity.Setup(c => c.SavedOutputMapping).Returns(string.Empty); activity.Setup(c => c.ResourceModel.WorkflowXaml).Returns(new StringBuilder(serviceDefStr)); activity.Setup(c => c.UnderlyingWebActivityObjectType).Returns(typeof(DsfDatabaseActivity)); //------------Execute Test--------------------------- activityDataMappingBuilder.SetupActivityData(activity.Object); //------------Assert Results------------------------- Assert.AreEqual(string.Empty, activityDataMappingBuilder.SavedInputMapping); Assert.AreEqual(string.Empty, activityDataMappingBuilder.SavedOutputMapping); Assert.AreEqual(typeof(DsfDatabaseActivity), activityDataMappingBuilder.ActivityType); }
public void ActivityDataMappingBuilder_Generate_WhenValidWorkflowWithDifferentRecordsetNameAndFirstColumn_ExpectOutputMappingWithDataListRecordsetName() { //------------Setup for test-------------------------- #region ServiceDef const string serviceDefStr = @"<Service ID=""3354620a-2af5-424d-9364-b60408c111ab"" Version=""1.0"" ServerID=""51a58300-7e9d-4927-a57b-e5d700b11b55"" Name=""bob"" ResourceType=""WorkflowService"" IsValid=""true""> <DisplayName>bob</DisplayName> <Category></Category> <IsNewWorkflow>false</IsNewWorkflow> <AuthorRoles></AuthorRoles> <Comment></Comment> <Tags></Tags> <IconPath>pack://application:,,,/Warewolf Studio;component/images/Workflow-32.png</IconPath> <HelpLink></HelpLink> <UnitTestTargetWorkflowService></UnitTestTargetWorkflowService> <DataList> <rec Description="""" IsEditable=""True"" ColumnIODirection=""Output""> <vale Description="""" IsEditable=""True"" ColumnIODirection=""Output"" /> </rec> </DataList> <Action Name=""InvokeWorkflow"" Type=""Workflow""> <XamlDefinition><Activity x:Class=""bob"" xmlns=""http://schemas.microsoft.com/netfx/2009/xaml/activities"" xmlns:av=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" xmlns:dc=""clr-namespace:Dev2.Common;assembly=Dev2.Common"" xmlns:ddc=""clr-namespace:Dev2.DataList.Contract;assembly=Dev2.Data"" xmlns:ddcb=""clr-namespace:Dev2.DataList.Contract.Binary_Objects;assembly=Dev2.Data"" xmlns:ddd=""clr-namespace:Dev2.Data.Decision;assembly=Dev2.Data"" xmlns:dddo=""clr-namespace:Dev2.Data.Decisions.Operations;assembly=Dev2.Data"" xmlns:ddsm=""clr-namespace:Dev2.Data.SystemTemplates.Models;assembly=Dev2.Data"" xmlns:dpe=""clr-namespace:Dev2.Providers.Errors;assembly=Dev2.Infrastructure"" xmlns:mva=""clr-namespace:Microsoft.VisualBasic.Activities;assembly=System.Activities"" xmlns:s=""clr-namespace:System;assembly=mscorlib"" xmlns:sap=""http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation"" xmlns:scg=""clr-namespace:System.Collections.Generic;assembly=mscorlib"" xmlns:sco=""clr-namespace:System.Collections.ObjectModel;assembly=mscorlib"" xmlns:uaba=""clr-namespace:Unlimited.Applications.BusinessDesignStudio.Activities;assembly=Dev2.Activities"" xmlns:uf=""clr-namespace:Unlimited.Framework;assembly=Dev2.Core"" xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml""><x:Members><x:Property Name=""AmbientDataList"" Type=""InOutArgument(scg:List(x:String))"" /><x:Property Name=""ParentWorkflowInstanceId"" Type=""InOutArgument(s:Guid)"" /><x:Property Name=""ParentServiceName"" Type=""InOutArgument(x:String)"" /></x:Members><sap:VirtualizedContainerService.HintSize>654,676</sap:VirtualizedContainerService.HintSize><mva:VisualBasic.Settings>Assembly references and imported namespaces serialized as XML namespaces</mva:VisualBasic.Settings><TextExpression.NamespacesForImplementation><scg:List x:TypeArguments=""x:String"" Capacity=""7""><x:String>Dev2.Common</x:String><x:String>Dev2.Data.Decisions.Operations</x:String><x:String>Dev2.Data.SystemTemplates.Models</x:String><x:String>Dev2.DataList.Contract</x:String><x:String>Dev2.DataList.Contract.Binary_Objects</x:String><x:String>Unlimited.Framework</x:String><x:String>Unlimited.Applications.BusinessDesignStudio.Activities</x:String></scg:List></TextExpression.NamespacesForImplementation><TextExpression.ReferencesForImplementation><sco:Collection x:TypeArguments=""AssemblyReference""><AssemblyReference>Dev2.Common</AssemblyReference><AssemblyReference>Dev2.Data</AssemblyReference><AssemblyReference>Dev2.Core</AssemblyReference><AssemblyReference>Dev2.Activities</AssemblyReference></sco:Collection></TextExpression.ReferencesForImplementation><Flowchart DisplayName=""bob"" sap:VirtualizedContainerService.HintSize=""614,636""><Flowchart.Variables><Variable x:TypeArguments=""scg:List(x:String)"" Name=""InstructionList"" /><Variable x:TypeArguments=""x:String"" Name=""LastResult"" /><Variable x:TypeArguments=""x:Boolean"" Name=""HasError"" /><Variable x:TypeArguments=""x:String"" Name=""ExplicitDataList"" /><Variable x:TypeArguments=""x:Boolean"" Name=""IsValid"" /><Variable x:TypeArguments=""uf:UnlimitedObject"" Name=""d"" /><Variable x:TypeArguments=""uaba:Util"" Name=""t"" /><Variable x:TypeArguments=""ddd:Dev2DataListDecisionHandler"" Name=""Dev2DecisionHandler"" /></Flowchart.Variables><sap:WorkflowViewStateService.ViewState><scg:Dictionary x:TypeArguments=""x:String, x:Object""><x:Boolean x:Key=""IsExpanded"">False</x:Boolean><av:Point x:Key=""ShapeLocation"">270,2.5</av:Point><av:Size x:Key=""ShapeSize"">60,75</av:Size><av:PointCollection x:Key=""ConnectorLocation"">300,77.5 300,127.5</av:PointCollection></scg:Dictionary></sap:WorkflowViewStateService.ViewState><Flowchart.StartNode><x:Reference>__ReferenceID0</x:Reference></Flowchart.StartNode><FlowStep x:Name=""__ReferenceID0""><sap:WorkflowViewStateService.ViewState><scg:Dictionary x:TypeArguments=""x:String, x:Object""><av:Point x:Key=""ShapeLocation"">185,127.5</av:Point><av:Size x:Key=""ShapeSize"">230,78</av:Size></scg:Dictionary></sap:WorkflowViewStateService.ViewState><uaba:DsfMultiAssignActivity Compiler=""{x:Null}"" CurrentResult=""{x:Null}"" DataObject=""{x:Null}"" ExplicitDataList=""{x:Null}"" InputMapping=""{x:Null}"" InputTransformation=""{x:Null}"" OnResumeKeepList=""{x:Null}"" OutputMapping=""{x:Null}"" ParentServiceID=""{x:Null}"" ParentServiceName=""{x:Null}"" ParentWorkflowInstanceId=""{x:Null}"" ResultTransformation=""{x:Null}"" ScenarioID=""{x:Null}"" ScopingObject=""{x:Null}"" ServiceHost=""{x:Null}"" SimulationOutput=""{x:Null}"" Add=""False"" CreateBookmark=""False"" DatabindRecursive=""False"" DisplayName=""Assign (1)"" HasError=""[HasError]"" sap:VirtualizedContainerService.HintSize=""230,78"" InstructionList=""[InstructionList]"" IsSimulationEnabled=""False"" IsUIStep=""False"" IsValid=""[IsValid]"" IsWorkflow=""False"" OnResumeClearAmbientDataList=""False"" OnResumeClearTags=""FormView,InstanceId,Bookmark,ParentWorkflowInstanceId,ParentServiceName,WebPage"" SimulationMode=""OnDemand"" UniqueID=""6b4f7d09-bc25-4b43-9c21-a213b8bc264b"" UpdateAllOccurrences=""False""><uaba:DsfMultiAssignActivity.AmbientDataList><InOutArgument x:TypeArguments=""scg:List(x:String)"" /></uaba:DsfMultiAssignActivity.AmbientDataList><uaba:DsfMultiAssignActivity.FieldsCollection><scg:List x:TypeArguments=""uaba:ActivityDTO"" Capacity=""4""><uaba:ActivityDTO ErrorMessage=""{x:Null}"" FieldName=""[[rec().vale]]"" FieldValue=""12"" IndexNumber=""1"" Inserted=""False"" IsFieldNameFocused=""False"" WatermarkTextValue=""Value"" WatermarkTextVariable=""[[Variable1]]""><uaba:ActivityDTO.Errors><scg:Dictionary x:TypeArguments=""x:String, scg:List(dpe:IActionableErrorInfo)"" /></uaba:ActivityDTO.Errors><uaba:ActivityDTO.OutList><scg:List x:TypeArguments=""x:String"" Capacity=""0"" /></uaba:ActivityDTO.OutList></uaba:ActivityDTO><uaba:ActivityDTO ErrorMessage=""{x:Null}"" FieldName="""" FieldValue="""" IndexNumber=""2"" Inserted=""False"" IsFieldNameFocused=""False"" WatermarkTextValue=""Value"" WatermarkTextVariable=""[[Variable2]]""><uaba:ActivityDTO.Errors><scg:Dictionary x:TypeArguments=""x:String, scg:List(dpe:IActionableErrorInfo)"" /></uaba:ActivityDTO.Errors><uaba:ActivityDTO.OutList><scg:List x:TypeArguments=""x:String"" Capacity=""0"" /></uaba:ActivityDTO.OutList></uaba:ActivityDTO></scg:List></uaba:DsfMultiAssignActivity.FieldsCollection><uaba:DsfMultiAssignActivity.ParentInstanceID><InOutArgument x:TypeArguments=""x:String"" /></uaba:DsfMultiAssignActivity.ParentInstanceID><sap:WorkflowViewStateService.ViewState><scg:Dictionary x:TypeArguments=""x:String, x:Object""><x:Boolean x:Key=""IsExpanded"">True</x:Boolean></scg:Dictionary></sap:WorkflowViewStateService.ViewState></uaba:DsfMultiAssignActivity></FlowStep></Flowchart></Activity></XamlDefinition> </Action> <ErrorMessages /> <Source /> <Signature xmlns=""http://www.w3.org/2000/09/xmldsig#""> <SignedInfo> <CanonicalizationMethod Algorithm=""http://www.w3.org/TR/2001/REC-xml-c14n-20010315"" /> <SignatureMethod Algorithm=""http://www.w3.org/2000/09/xmldsig#rsa-sha1"" /> <Reference URI=""""> <Transforms> <Transform Algorithm=""http://www.w3.org/2000/09/xmldsig#enveloped-signature"" /> </Transforms> <DigestMethod Algorithm=""http://www.w3.org/2000/09/xmldsig#sha1"" /> <DigestValue>vWmN0jnD5L5etfUXFuDmTvVceeg=</DigestValue> </Reference> </SignedInfo> <SignatureValue>m8ogAOvBBm4Gue8hZ0vzv5KSgsg/xqCK4hFlxLzTsduLLYTmOmB1VPDelwYZ7OwjnYrQtCf7Rv1rF/r3lhpjtDh4DltZ9j55hWq3zzckItGkAYJHWkNzx3mto+hrrz7cYaDzgLcaNhF11XGSOvU3mbgff4vTFkai9och+0aASu8=</SignatureValue> </Signature> </Service>"; const string datalistFragment = @"<DataList><recset1 Description="""" IsEditable=""True"" ColumnIODirection=""Output"" ><vale Description="""" IsEditable=""True"" ColumnIODirection=""Output"" /><valeSecond Description="""" IsEditable=""True"" ColumnIODirection=""Output"" /></recset1></DataList>"; #endregion var activityDataMappingBuilder = new ActivityDataMappingBuilder { DataList = "<DataList><recordSet><vale/></recordSet></DataList>" }; Mock<IContextualResourceModel> resourceModel = new Mock<IContextualResourceModel>(); resourceModel.Setup(c => c.DataList).Returns("<DataList/>"); Mock<IWebActivity> activity = new Mock<IWebActivity>(); activity.Setup(c => c.SavedInputMapping).Returns(string.Empty); activity.Setup(c => c.SavedOutputMapping).Returns(string.Empty); activity.Setup(c => c.ResourceModel.WorkflowXaml).Returns(new StringBuilder(serviceDefStr)); activity.Setup(c => c.UnderlyingWebActivityObjectType).Returns(typeof(DsfActivity)); activity.Setup(c => c.ResourceModel.DataList).Returns(datalistFragment); activityDataMappingBuilder.SetupActivityData(activity.Object); //------------Execute Test--------------------------- var result = activityDataMappingBuilder.Generate(); //------------Assert Results------------------------- // check counts first Assert.AreEqual(2, result.Outputs.Count); // now check data Assert.AreEqual("[[recset1().vale]]", result.Outputs[0].Value); Assert.AreEqual("[[recset1().valeSecond]]", result.Outputs[1].Value); // check counts first Assert.AreEqual(0, result.Inputs.Count); }
internal void Initialize(IWebActivity activity) { // -- NEW ;) Activity = activity; ActivityName = activity.ServiceName; var activeDataList = string.Empty; if(DataListSingleton.ActiveDataList != null) { activeDataList = DataListSingleton.DataListAsXmlString; } ActivityDataMappingBuilder ioBuilder = new ActivityDataMappingBuilder { DataList = activeDataList, }; ioBuilder.SetupActivityData(activity); var mappingData = ioBuilder.Generate(); // save model data //Outputs = mappingData.Outputs.ToObservableCollection(); foreach(var ioViewModel in mappingData.Outputs) { Outputs.Add(ioViewModel); } //Inputs = mappingData.Inputs.ToObservableCollection(); foreach(var ioViewModel in mappingData.Inputs) { Inputs.Add(ioViewModel); } // update special fields on the model?! var toSaveOutputMapping = ioBuilder.SavedOutputMapping; var toSaveInputMapping = ioBuilder.SavedInputMapping; XmlOutput = toSaveOutputMapping; Activity.SavedOutputMapping = toSaveOutputMapping; Activity.LiveOutputMapping = toSaveOutputMapping; XmlOutput = (XmlOutput + toSaveInputMapping); Activity.SavedInputMapping = toSaveInputMapping; Activity.LiveInputMapping = toSaveInputMapping; }