Exemplo n.º 1
0
        public MethodExecutor(Activity invokingActivity, Type targetType, InArgument targetObject,
            Collection<Argument> parameters, RuntimeArgument returnObject)
        {
            Fx.Assert(invokingActivity != null, "Must provide invokingActivity");
            Fx.Assert(targetType != null || (targetObject != null), "Must provide targetType or targetObject");
            Fx.Assert(parameters != null, "Must provide parameters");
            // returnObject is optional 

            this.invokingActivity = invokingActivity;
            this.targetType = targetType;
            this.targetObject = targetObject;
            this.parameters = parameters;
            this.returnObject = returnObject;
        }
        public CompensationParticipant(Variable<long> compensationId)
            : base()
        {
            this.compensationId = compensationId;

            this.currentCompensationToken = new Variable<CompensationToken>();

            DefaultCompensation = new DefaultCompensation()
                {
                    Target = new InArgument<CompensationToken>(this.currentCompensationToken),
                };

            DefaultConfirmation = new DefaultConfirmation()
                {
                    Target = new InArgument<CompensationToken>(this.currentCompensationToken),
                };
        }
Exemplo n.º 3
0
 public ExpressionEvaluatorWithBody()
 {
     _expressionResult = new InArgument <T>();
 }
        public void DsfWebGetActivity_Execute_WithValidTextResponse_ShouldSetVariables()
        {
            //------------Setup for test--------------------------
            const string response = "{\"Location\": \"Paris\",\"Time\": \"May 29, 2013 - 09:00 AM EDT / 2013.05.29 1300 UTC\"," +
                                    "\"Wind\": \"from the NW (320 degrees) at 10 MPH (9 KT) (direction variable):0\"," +
                                    "\"Visibility\": \"greater than 7 mile(s):0\"," +
                                    "\"Temperature\": \"59 F (15 C)\"," +
                                    "\"DewPoint\": \"41 F (5 C)\"," +
                                    "\"RelativeHumidity\": \"51%\"," +
                                    "\"Pressure\": \"29.65 in. Hg (1004 hPa)\"," +
                                    "\"Status\": \"Success\"" +
                                    "}";
            var environment = new ExecutionEnvironment();

            environment.Assign("[[City]]", "PMB", 0);
            environment.Assign("[[CountryName]]", "South Africa", 0);
            var dsfWebGetActivity = new TestDsfWebGetActivity();

            dsfWebGetActivity.ResourceCatalog = new Mock <IResourceCatalog>().Object;
            var serviceInputs = new List <IServiceInput> {
                new ServiceInput("CityName", "[[City]]"), new ServiceInput("Country", "[[CountryName]]")
            };
            var serviceOutputs = new List <IServiceOutputMapping> {
                new ServiceOutputMapping("Response", "[[Response]]", "")
            };

            dsfWebGetActivity.Inputs  = serviceInputs;
            dsfWebGetActivity.Outputs = serviceOutputs;
            var serviceXml = XmlResource.Fetch("WebService");
            var service    = new WebService(serviceXml)
            {
                RequestResponse = response
            };

            dsfWebGetActivity.OutputDescription = service.GetOutputDescription();
            dsfWebGetActivity.ResponseFromWeb   = response;
            var dataObjectMock = new Mock <IDSFDataObject>();

            dataObjectMock.Setup(o => o.Environment).Returns(environment);
            dataObjectMock.Setup(o => o.EsbChannel).Returns(new Mock <IEsbChannel>().Object);
            dsfWebGetActivity.ResourceID = InArgument <Guid> .FromValue(Guid.Empty);

            dsfWebGetActivity.QueryString = "";

            dsfWebGetActivity.SourceId          = Guid.Empty;
            dsfWebGetActivity.Headers           = new List <INameValue>();
            dsfWebGetActivity.OutputDescription = new OutputDescription();
            dsfWebGetActivity.OutputDescription.DataSourceShapes.Add(new DataSourceShape()
            {
                Paths = new List <IPath>()
                {
                    new StringPath()
                    {
                        ActualPath = "[[Response]]", OutputExpression = "[[Response]]"
                    }
                }
            });

            //------------Execute Test---------------------------
            dsfWebGetActivity.Execute(dataObjectMock.Object, 0);
            //------------Assert Results-------------------------
            Assert.IsNotNull(dsfWebGetActivity.OutputDescription);
            Assert.AreEqual(response, ExecutionEnvironment.WarewolfEvalResultToString(environment.Eval("[[Response]]", 0)));
        }
            void SetHandle(object value)
            {
                InArgument handle = (InArgument)(value is ModelItem ? ((ModelItem)value).GetCurrentValue() : value);

                this.ReflectedObject.Properties[HandleProperty].SetValue(handle);
            }
Exemplo n.º 6
0
 public AsyncWaitCallbackMethodExecutor(AsyncWaitCallbackMethodExecutor copy, Type targetType, InArgument targetObject,
                                        Collection <Argument> parameters, RuntimeArgument returnObject) :
     base(copy.invokingActivity, targetType, targetObject, parameters, returnObject)
 {
     this.asyncMethod = copy.asyncMethod;
     this.asyncFunc   = copy.asyncFunc;
 }
Exemplo n.º 7
0
 public AsyncPatternMethodExecutor(CodeActivityMetadata metadata, MethodInfo beginMethod, MethodInfo endMethod,
                                   Activity invokingActivity, Type targetType, InArgument targetObject,
                                   Collection <Argument> parameters, RuntimeArgument returnObject,
                                   MruCache <MethodInfo, Func <object, object[], object> > funcCache,
                                   ReaderWriterLockSlim locker)
     : base(invokingActivity, targetType, targetObject, parameters, returnObject)
 {
     Fx.Assert(beginMethod != null && endMethod != null, "Must provide beginMethod and endMethod");
     this.beginMethod = beginMethod;
     this.endMethod   = endMethod;
     this.beginFunc   = MethodCallExpressionHelper.GetFunc(metadata, beginMethod, funcCache, locker);
     this.endFunc     = MethodCallExpressionHelper.GetFunc(metadata, endMethod, funcCache, locker);
 }
Exemplo n.º 8
0
 /// <summary>Assigns a value to the specified <see cref="T:System.Activities.InArgument`1" />.</summary>
 /// <param name="context"></param>
 /// <param name="argument">The argument to receive the new value.</param>
 /// <param name="value">The new value of the argument.</param>
 /// <typeparam name="T">The type of the argument.</typeparam>
 public static void SetValue <T>(this IExtendedWorkflowContext context, InArgument <T> argument, T value)
 {
     context.CodeActivityContext.SetValue(argument, value);
 }
Exemplo n.º 9
0
 public AsyncPatternMethodExecutor(CodeActivityMetadata metadata, MethodInfo beginMethod, MethodInfo endMethod,
     Activity invokingActivity, Type targetType, InArgument targetObject,
     Collection<Argument> parameters, RuntimeArgument returnObject,
      MruCache<MethodInfo, Func<object, object[], object>> funcCache,
     ReaderWriterLockSlim locker)
     : base(invokingActivity, targetType, targetObject, parameters, returnObject)
 {
     Fx.Assert(beginMethod != null && endMethod != null, "Must provide beginMethod and endMethod");
     this.beginMethod = beginMethod;
     this.endMethod = endMethod;
     this.beginFunc = MethodCallExpressionHelper.GetFunc(metadata, beginMethod, funcCache, locker);
     this.endFunc = MethodCallExpressionHelper.GetFunc(metadata, endMethod, funcCache, locker);
 }
        public void DsfWebDeleteActivity_Execute_WithValidXmlEscaped_ShouldSetVariables()
        {
            //------------Setup for test--------------------------
            const string response = "<CurrentWeather>" +
                                    "<Location>&lt;Paris&gt;</Location>" +
                                    "<Time>May 29, 2013 - 09:00 AM EDT / 2013.05.29 1300 UTC</Time>" +
                                    "<Wind>from the NW (320 degrees) at 10 MPH (9 KT) (direction variable):0</Wind>" +
                                    "<Visibility>&lt;greater than 7 mile(s):0&gt;</Visibility>" +
                                    "<Temperature> 59 F (15 C)</Temperature>" +
                                    "<DewPoint> 41 F (5 C)</DewPoint>" +
                                    "<RelativeHumidity> 51%</RelativeHumidity>" +
                                    "<Pressure> 29.65 in. Hg (1004 hPa)</Pressure>" +
                                    "<Status>Success</Status>" +
                                    "</CurrentWeather>";
            var environment = new ExecutionEnvironment();

            environment.Assign("[[City]]", "PMB", 0);
            environment.Assign("[[CountryName]]", "South Africa", 0);
            var dsfWebDeleteActivity = CreateTestDeleteActivity();
            var serviceInputs        = new List <IServiceInput> {
                new ServiceInput("CityName", "[[City]]"), new ServiceInput("Country", "[[CountryName]]")
            };
            var serviceOutputs = new List <IServiceOutputMapping>
            {
                new ServiceOutputMapping("Location", "[[weather().Location]]", "weather")
                , new ServiceOutputMapping("Time", "[[weather().Time]]", "weather")
                , new ServiceOutputMapping("Wind", "[[weather().Wind]]", "weather")
                , new ServiceOutputMapping("Visibility", "[[Visibility]]", "")
            };

            dsfWebDeleteActivity.Inputs  = serviceInputs;
            dsfWebDeleteActivity.Outputs = serviceOutputs;
            var serviceXml = XmlResource.Fetch("WebService");
            var service    = new WebService(serviceXml)
            {
                RequestResponse = response
            };

            dsfWebDeleteActivity.OutputDescription = service.GetOutputDescription();
            dsfWebDeleteActivity.ResponseFromWeb   = response;
            var dataObjectMock = new Mock <IDSFDataObject>();

            dataObjectMock.Setup(o => o.Environment).Returns(environment);
            dataObjectMock.Setup(o => o.EsbChannel).Returns(new Mock <IEsbChannel>().Object);
            dsfWebDeleteActivity.ResourceID = InArgument <Guid> .FromValue(Guid.Empty);

            dsfWebDeleteActivity.QueryString = "";
            //dsfWebPostActivity.PostData = "";
            dsfWebDeleteActivity.SourceId = Guid.Empty;
            dsfWebDeleteActivity.Headers  = new List <INameValue>();
            //------------Execute Test---------------------------
            dsfWebDeleteActivity.Execute(dataObjectMock.Object, 0);
            //------------Assert Results-------------------------
            Assert.IsNotNull(dsfWebDeleteActivity.OutputDescription);
            var visibility = ExecutionEnvironment.WarewolfEvalResultToString(environment.Eval("[[Visibility]]", 0));

            Assert.AreEqual("<greater than 7 mile(s):0>", visibility);
            var location = ExecutionEnvironment.WarewolfEvalResultToString(environment.Eval("[[weather().Location]]", 0));

            Assert.AreEqual("<Paris>", location);
            var time = ExecutionEnvironment.WarewolfEvalResultToString(environment.Eval("[[weather().Time]]", 0));

            Assert.AreEqual("May 29, 2013 - 09:00 AM EDT / 2013.05.29 1300 UTC", time);
            var wind = ExecutionEnvironment.WarewolfEvalResultToString(environment.Eval("[[weather().Wind]]", 0));

            Assert.AreEqual("from the NW (320 degrees) at 10 MPH (9 KT) (direction variable):0", wind);
        }
        /// <summary>
        /// Returns an <see cref="Activity"/> that invokes the action with the specified arguments.
        /// </summary>
        /// <typeparam name="TArg"></typeparam>
        /// <param name="action"></param>
        /// <param name="arg"></param>
        /// <param name="displayName"></param>
        /// <returns></returns>
        public static InvokeAction <TArg> InvokeDelegate <TArg>(ActivityAction <TArg> action, InArgument <TArg> arg, string displayName = null)
        {
            if (action == null)
            {
                throw new ArgumentNullException(nameof(action));
            }

            return(new InvokeAction <TArg>()
            {
                DisplayName = displayName,
                Action = action,
                Argument = arg,
            });
        }
 public static T? GetArgumentLiteralValue<T>(this InArgument<T> inArgument)
     where T : struct
 {
     return (inArgument?.Expression as Literal<T>)?.Value;
 }
 public static string GetArgumentLiteralValue(this InArgument<string> inArgument)
 {
     return (inArgument?.Expression as Literal<string>)?.Value;
 }
Exemplo n.º 14
0
 /// <summary>Gets the value of the specified <see cref="T:System.Activities.InArgument`1" />.</summary>
 /// <param name="context"></param>
 /// <param name="argument">The argument to inspect.</param>
 /// <typeparam name="T">The type of the argument.</typeparam>
 /// <returns>The value of the argument.</returns>
 public static T GetValue <T>(this IExtendedWorkflowContext context, InArgument <T> argument)
 {
     return(context.CodeActivityContext.GetValue(argument));
 }
Exemplo n.º 15
0
 public static T Get <T>(this InArgument <T> arg, IExtendedWorkflowContext context)
 {
     return(arg.Get(context.CodeActivityContext));
 }
Exemplo n.º 16
0
 /// <summary>
 /// 初始化
 /// </summary>
 /// <param name="flowNodeIndex">对应的索引</param>
 /// <param name="actioners"></param>
 public Human(int flowNodeIndex, Activity<string[]> actioners)
     : base(flowNodeIndex)
 {
     this.Actioners = new InArgument<string[]>(actioners);
 }
Exemplo n.º 17
0
 public Increment()
 {
     Value = new VisualBasicValue <int>("1");
 }
Exemplo n.º 18
0
 public AsyncWaitCallbackMethodExecutor(CodeActivityMetadata metadata, MethodInfo asyncMethod, Activity invokingActivity,
     Type targetType, InArgument targetObject, Collection<Argument> parameters,
     RuntimeArgument returnObject,
      MruCache<MethodInfo, Func<object, object[], object>> funcCache,
     ReaderWriterLockSlim locker)
     : base(invokingActivity, targetType, targetObject, parameters, returnObject)
 {
     Fx.Assert(asyncMethod != null, "Must provide asyncMethod");
     this.asyncMethod = asyncMethod;
     this.asyncFunc = MethodCallExpressionHelper.GetFunc(metadata, asyncMethod, funcCache, locker);
 }
Exemplo n.º 19
0
 public GetExecutionListActivity()
 {
     DisplayName = "企业/自然人失信人信息查询";
     Skip        = new InArgument <int>(0);
 }
Exemplo n.º 20
0
 protected GetMailActivity()
 {
     Top = new InArgument <int>(30);
 }
 public static T GetValueOrDefault <T>(this AsyncCodeActivityContext context, InArgument <T> arg, T defaultValue = default(T))
 {
     return(arg.Expression != null
            ? arg.Get(context)       // User provided a value
            : defaultValue);         // Field was left blank
 }
Exemplo n.º 22
0
 public AsyncPatternMethodExecutor(AsyncPatternMethodExecutor copy, Type targetType, InArgument targetObject,
                                   Collection <Argument> parameters, RuntimeArgument returnObject)
     : base(copy.invokingActivity, targetType, targetObject, parameters, returnObject)
 {
     this.beginMethod = copy.beginMethod;
     this.endMethod   = copy.endMethod;
     this.beginFunc   = copy.beginFunc;
     this.endFunc     = copy.endFunc;
 }
Exemplo n.º 23
0
        /// <summary>
        /// Computes the bitwise logic AND of two values.
        /// </summary>
        /// <typeparam name="TLeft"></typeparam>
        /// <typeparam name="TRight"
        /// <typeparam name="TResult"></typeparam>
        /// <param name="left"></param>
        /// <param name="right"></param>
        /// <param name="displayName"></param>
        /// <returns></returns>
        public static And <TLeft, TRight, TResult> And <TLeft, TRight, TResult>(InArgument <TLeft> left, InArgument <TRight> right, string displayName = null)
        {
            if (left == null)
            {
                throw new ArgumentNullException(nameof(left));
            }
            if (right == null)
            {
                throw new ArgumentNullException(nameof(right));
            }

            return(new And <TLeft, TRight, TResult>()
            {
                DisplayName = displayName,
                Left = left,
                Right = right,
            });
        }
Exemplo n.º 24
0
        private static Activity HandleBinaryExpression <TLeft, TRight, TResult>(BinaryOperator op, TestExpression left, TestExpression right)
        {
            Activity           we           = null;
            InArgument <TLeft> leftArgument = (InArgument <TLeft>)TestExpression.GetInArgumentFromExpectedNode <TLeft>(left);

            leftArgument.EvaluationOrder = 0;
            InArgument <TRight> rightArgument = (InArgument <TRight>)TestExpression.GetInArgumentFromExpectedNode <TRight>(right);

            rightArgument.EvaluationOrder = 1;

            switch (op)
            {
            case BinaryOperator.Add:
                we = new Add <TLeft, TRight, TResult>()
                {
                    Checked = false,
                    Left    = leftArgument,
                    Right   = rightArgument
                };
                break;

            case BinaryOperator.And:
                we = new And <TLeft, TRight, TResult>()
                {
                    Left  = leftArgument,
                    Right = rightArgument
                };
                break;

            case BinaryOperator.AndAlso:
                we = new AndAlso()
                {
                    Left  = TestExpression.GetWorkflowElementFromExpectedNode <bool>(left),
                    Right = TestExpression.GetWorkflowElementFromExpectedNode <bool>(right)
                };
                break;

            case BinaryOperator.CheckedAdd:
                we = new Add <TLeft, TRight, TResult>()
                {
                    Checked = true,
                    Left    = leftArgument,
                    Right   = rightArgument
                };
                break;

            case BinaryOperator.CheckedMultiply:
                we = new Multiply <TLeft, TRight, TResult>()
                {
                    Checked = true,
                    Left    = leftArgument,
                    Right   = rightArgument
                };
                break;

            case BinaryOperator.CheckedSubtract:
                we = new Subtract <TLeft, TRight, TResult>()
                {
                    Checked = true,
                    Left    = leftArgument,
                    Right   = rightArgument
                };
                break;

            case BinaryOperator.Divide:
                we = new Divide <TLeft, TRight, TResult>()
                {
                    Left  = leftArgument,
                    Right = rightArgument
                };
                break;

            case BinaryOperator.Equal:
                we = new Equal <TLeft, TRight, TResult>()
                {
                    Left  = leftArgument,
                    Right = rightArgument
                };
                break;

            case BinaryOperator.GreaterThan:
                we = new GreaterThan <TLeft, TRight, TResult>()
                {
                    Left  = leftArgument,
                    Right = rightArgument
                };
                break;

            case BinaryOperator.GreaterThanOrEqual:
                we = new GreaterThanOrEqual <TLeft, TRight, TResult>()
                {
                    Left  = leftArgument,
                    Right = rightArgument
                };
                break;

            case BinaryOperator.LessThan:
                we = new LessThan <TLeft, TRight, TResult>()
                {
                    Left  = leftArgument,
                    Right = rightArgument
                };
                break;

            case BinaryOperator.LessThanOrEqual:
                we = new LessThanOrEqual <TLeft, TRight, TResult>()
                {
                    Left  = leftArgument,
                    Right = rightArgument
                };
                break;

            case BinaryOperator.Or:
                we = new Or <TLeft, TRight, TResult>()
                {
                    Left  = leftArgument,
                    Right = rightArgument
                };
                break;

            case BinaryOperator.Multiply:
                we = new Multiply <TLeft, TRight, TResult>()
                {
                    Checked = false,
                    Left    = leftArgument,
                    Right   = rightArgument
                };
                break;

            case BinaryOperator.NotEqual:
                we = new NotEqual <TLeft, TRight, TResult>()
                {
                    Left  = leftArgument,
                    Right = rightArgument
                };
                break;

            case BinaryOperator.OrElse:
                we = new OrElse()
                {
                    Left  = TestExpression.GetWorkflowElementFromExpectedNode <bool>(left),
                    Right = TestExpression.GetWorkflowElementFromExpectedNode <bool>(right)
                };
                break;

            case BinaryOperator.Subtract:
                we = new Subtract <TLeft, TRight, TResult>()
                {
                    Checked = false,
                    Left    = leftArgument,
                    Right   = rightArgument
                };
                break;

            default:
                throw new NotSupportedException(string.Format("Operator: {0} is unsupported", op.ToString()));
            }

            return(we);
        }
Exemplo n.º 25
0
Arquivo: If.cs Projeto: wforney/corewf
 public If(InArgument <bool> condition)
     : this()
 {
     this.Condition = condition ?? throw FxTrace.Exception.ArgumentNull(nameof(condition));
 }
Exemplo n.º 26
0
 public static WebRequestDataDto CreateRequestDataDto(WebRequestMethod requestMethod, InArgument <string> type, string displayName) => new WebRequestDataDto()
 {
     WebRequestMethod = requestMethod,
     DisplayName      = displayName,
     Type             = type
 };
 public static TArgument TakeValue <TArgument>(this InArgument <TArgument> param)
 {
     return(param.Value);
 }
 public CallMessageStateless()
 {
     VersionDate = new InArgument <string>("2020-04-01");
 }
Exemplo n.º 29
0
        public void WebPostActivity_Execute_WithInValidWebResponse_ShouldError()
        {
            //------------Setup for test--------------------------
            const string response = "{\"Location\": \"Paris\",\"Time\": \"May 29, 2013 - 09:00 AM EDT / 2013.05.29 1300 UTC\"," +
                                    "\"Wind\": \"from the NW (320 degrees) at 10 MPH (9 KT) (direction variable):0\"," +
                                    "\"Visibility\": \"greater than 7 mile(s):0\"," +
                                    "\"Temperature\": \"59 F (15 C)\"," +
                                    "\"DewPoint\": \"41 F (5 C)\"," +
                                    "\"RelativeHumidity\": \"51%\"," +
                                    "\"Pressure\": \"29.65 in. Hg (1004 hPa)\"," +
                                    "\"Status\": \"Success\"" +
                                    "}";
            const string invalidResponse = "{\"Location\" \"Paris\",\"Time\": \"May 29, 2013 - 09:00 AM EDT / 2013.05.29 1300 UTC\"," +
                                           "\"Wind\": \"from the NW (320 degrees) at 10 MPH (9 KT) (direction variable):0\"," +
                                           "\"Visibility\": \"greater than 7 mile(s):0\"," +
                                           "\"Temperature\": \"59 F (15 C)\"," +
                                           "\"DewPoint\": \"41 F (5 C)\"," +
                                           "\"RelativeHumidity\": \"51%\"," +
                                           "\"Pressure\": \"29.65 in. Hg (1004 hPa)\"," +
                                           "\"Status\": \"Success\"" +
                                           "";
            var environment = new ExecutionEnvironment();

            environment.Assign("[[City]]", "PMB", 0);
            environment.Assign("[[CountryName]]", "South Africa", 0);
            var webPostActivity = new TestWebPostActivity
            {
                ResourceCatalog = new Mock <IResourceCatalog>().Object,
            };
            var serviceInputs = new List <IServiceInput> {
                new ServiceInput("CityName", "[[City]]"), new ServiceInput("Country", "[[CountryName]]")
            };
            var serviceOutputs = new List <IServiceOutputMapping> {
                new ServiceOutputMapping("Location", "[[weather().Location]]", "weather"), new ServiceOutputMapping("Time", "[[weather().Time]]", "weather"), new ServiceOutputMapping("Wind", "[[weather().Wind]]", "weather"), new ServiceOutputMapping("Visibility", "[[Visibility]]", "")
            };

            webPostActivity.Inputs  = serviceInputs;
            webPostActivity.Outputs = serviceOutputs;
            var serviceXml = XmlResource.Fetch("WebService");
            var service    = new WebService(serviceXml)
            {
                RequestResponse = response
            };

            webPostActivity.OutputDescription = service.GetOutputDescription();
            webPostActivity.ResponseFromWeb   = invalidResponse;
            var dataObjectMock = new Mock <IDSFDataObject>();

            dataObjectMock.Setup(o => o.Environment).Returns(environment);
            dataObjectMock.Setup(o => o.EsbChannel).Returns(new Mock <IEsbChannel>().Object);
            webPostActivity.ResourceID = InArgument <Guid> .FromValue(Guid.Empty);

            webPostActivity.QueryString = "";
            webPostActivity.PostData    = "";
            webPostActivity.SourceId    = Guid.Empty;
            webPostActivity.Headers     = new List <INameValue>();
            //------------Execute Test---------------------------
            webPostActivity.Execute(dataObjectMock.Object, 0);
            //------------Assert Results-------------------------
            Assert.IsNotNull(webPostActivity.OutputDescription);
            Assert.AreEqual(1, environment.Errors.Count);
            StringAssert.Contains(environment.Errors.ToList()[0], "Invalid character after parsing property name");
        }
Exemplo n.º 30
0
        public void WebPostActivity_GetDebugInputs_GivenMockEnvironment_ShouldAddDebugInputItems()
        {
            //---------------Set up test pack-------------------
            const string response = "{\"Location\": \"Paris\",\"Time\": \"May 29, 2013 - 09:00 AM EDT / 2013.05.29 1300 UTC\"," +
                                    "\"Wind\": \"from the NW (320 degrees) at 10 MPH (9 KT) (direction variable):0\"," +
                                    "\"Visibility\": \"greater than 7 mile(s):0\"," +
                                    "\"Temperature\": \"59 F (15 C)\"," +
                                    "\"DewPoint\": \"41 F (5 C)\"," +
                                    "\"RelativeHumidity\": \"51%\"," +
                                    "\"Pressure\": \"29.65 in. Hg (1004 hPa)\"," +
                                    "\"Status\": \"Success\"" +
                                    "}";
            var environment = new ExecutionEnvironment();

            environment.Assign("[[City]]", "PMB", 0);
            environment.Assign("[[CountryName]]", "South Africa", 0);
            environment.Assign("[[Post]]", "Some data", 0);
            var webPostActivity = new TestWebPostActivity
            {
                Headers = new List <INameValue> {
                    new NameValue("Header 1", "[[City]]")
                },
                QueryString = "http://www.testing.com/[[CountryName]]",
                PostData    = "This is post:[[Post]]"
            };
            var serviceOutputs = new List <IServiceOutputMapping> {
                new ServiceOutputMapping("Location", "[[weather().Location]]", "weather"), new ServiceOutputMapping("Time", "[[weather().Time]]", "weather"), new ServiceOutputMapping("Wind", "[[weather().Wind]]", "weather"), new ServiceOutputMapping("Visibility", "[[Visibility]]", "")
            };

            webPostActivity.Outputs = serviceOutputs;
            var serviceXml = XmlResource.Fetch("WebService");
            var service    = new WebService(serviceXml)
            {
                RequestResponse = response
            };

            webPostActivity.OutputDescription = service.GetOutputDescription();
            webPostActivity.ResponseFromWeb   = response;
            var dataObjectMock = new Mock <IDSFDataObject>();

            dataObjectMock.Setup(o => o.Environment).Returns(environment);
            dataObjectMock.Setup(o => o.EsbChannel).Returns(new Mock <IEsbChannel>().Object);
            webPostActivity.ResourceID = InArgument <Guid> .FromValue(Guid.Empty);

            var cat = new Mock <IResourceCatalog>();
            var src = new WebSource {
                Address = "www.example.com"
            };

            cat.Setup(a => a.GetResource <WebSource>(It.IsAny <Guid>(), It.IsAny <Guid>())).Returns(src);
            webPostActivity.ResourceCatalog = cat.Object;
            //---------------Assert Precondition----------------
            Assert.IsNotNull(environment);
            Assert.IsNotNull(webPostActivity);
            //---------------Execute Test ----------------------
            var debugInputs = webPostActivity.GetDebugInputs(environment, 0);

            //---------------Test Result -----------------------
            Assert.IsNotNull(debugInputs);
            Assert.AreEqual(4, debugInputs.Count);
        }
Exemplo n.º 31
0
        public void WebPostActivity_ExecutionImpl_ResponseManager_PushResponseIntoEnvironment_GivenJsonResponse_MappedToRecodSet_ShouldSucess()
        {
            //-----------------------Arrange-------------------------
            const string json                  = "{\"Messanger\":\"jSon response from the request\"}";
            var          response              = Convert.ToBase64String(json.ToBytesArray());
            const string mappingFrom           = "mapFrom";
            const string recordSet             = "recset";
            const string mapTo                 = "mapTo";
            const string variableNameMappingTo = "[[recset().mapTo]]";

            var environment = new ExecutionEnvironment();

            var mockEsbChannel           = new Mock <IEsbChannel>();
            var mockDSFDataObject        = new Mock <IDSFDataObject>();
            var mockExecutionEnvironment = new Mock <IExecutionEnvironment>();

            var errorResultTO = new ErrorResultTO();

            using (var service = new WebService(XmlResource.Fetch("WebService"))
            {
                RequestResponse = response
            })
            {
                mockDSFDataObject.Setup(o => o.Environment).Returns(environment);
                mockDSFDataObject.Setup(o => o.EsbChannel).Returns(new Mock <IEsbChannel>().Object);

                var dsfWebGetActivity = new TestWebPostActivity
                {
                    OutputDescription = service.GetOutputDescription(),
                    ResourceID        = InArgument <Guid> .FromValue(Guid.Empty),
                    QueryString       = "test Query",
                    Headers           = new List <INameValue>(),
                    ResponseFromWeb   = response,
                    IsObject          = false,
                    Outputs           = new List <IServiceOutputMapping>
                    {
                        {
                            new ServiceOutputMapping
                            {
                                MappedFrom    = mappingFrom,
                                MappedTo      = mapTo,
                                RecordSetName = recordSet
                            }
                        }
                    }
                };
                //-----------------------Act-----------------------------
                dsfWebGetActivity.TestExecutionImpl(mockEsbChannel.Object, mockDSFDataObject.Object, "Test Inputs", "Test Outputs", out errorResultTO, 0);
                //-----------------------Assert--------------------------
                Assert.IsFalse(errorResultTO.HasErrors());

                //assert first DataSourceShapes
                var resourceManager   = dsfWebGetActivity.ResponseManager;
                var outputDescription = resourceManager.OutputDescription;
                var dataShapes        = outputDescription.DataSourceShapes;
                var paths             = dataShapes.First().Paths;
                Assert.IsNotNull(outputDescription);
                Assert.AreEqual("Messanger", paths.First().ActualPath);
                Assert.AreEqual("Messanger", paths.First().DisplayPath);
                Assert.AreEqual(variableNameMappingTo, paths.First().OutputExpression);
                Assert.AreEqual("jSon response from the request", paths.First().SampleData);

                //assert execution environment
                var envirVariable = environment.Eval(recordSet, 0);
                var ress          = envirVariable as CommonFunctions.WarewolfEvalResult.WarewolfAtomResult;
                Assert.IsNotNull(envirVariable);
                Assert.IsFalse(ress.Item.IsNothing, "Item should contain the recset mapped to the messanger key");
            }
        }
Exemplo n.º 32
0
 /// <summary>
 /// 初始化
 /// </summary>
 /// <param name="actioners"></param>
 public Human(Activity<string[]> actioners)
     : base()
 {
     this.Actioners = new InArgument<string[]>(actioners);
 }
Exemplo n.º 33
0
 public XmlParseDynamicValue(InArgument <string> source, OutArgument <DynamicValue> result)
 {
     this.Source = source;
     base.Result = result;
 }
Exemplo n.º 34
0
 public SyncMethodExecutor(SyncMethodExecutor copy, Type targetType, InArgument targetObject, Collection<Argument> parameters,
     RuntimeArgument returnObject)
     : base(copy.invokingActivity, targetType, targetObject, parameters, returnObject)
 {
     this.syncMethod = copy.syncMethod;
     this.func = copy.func;
 }
 public AsyncPatternMethodExecutor(MethodInfo beginMethod, MethodInfo endMethod, Activity invokingActivity, Type targetType, InArgument targetObject, Collection <Argument> parameters, RuntimeArgument returnObject) : base(invokingActivity, targetType, targetObject, parameters, returnObject)
 {
     this.beginMethod = beginMethod;
     this.endMethod   = endMethod;
 }
Exemplo n.º 36
0
 public AsyncPatternMethodExecutor(AsyncPatternMethodExecutor copy, Type targetType, InArgument targetObject,
     Collection<Argument> parameters, RuntimeArgument returnObject)
     : base(copy.invokingActivity, targetType, targetObject, parameters, returnObject)
 {
     this.beginMethod = copy.beginMethod;
     this.endMethod = copy.endMethod;
     this.beginFunc = copy.beginFunc;
     this.endFunc = copy.endFunc;
 }
 public SyncMethodExecutor(MethodInfo syncMethod, Activity invokingActivity, Type targetType, InArgument targetObject, Collection <Argument> parameters, RuntimeArgument returnObject) : base(invokingActivity, targetType, targetObject, parameters, returnObject)
 {
     this.syncMethod = syncMethod;
 }
Exemplo n.º 38
0
 public AsyncWaitCallbackMethodExecutor(AsyncWaitCallbackMethodExecutor copy, Type targetType, InArgument targetObject, 
     Collection<Argument> parameters, RuntimeArgument returnObject) : 
     base(copy.invokingActivity, targetType, targetObject, parameters, returnObject)
 {
     this.asyncMethod = copy.asyncMethod;
     this.asyncFunc = copy.asyncFunc;
 }
 protected ModelItem ArgumentToModelItem(InArgument arg, EditingContext editingContext)
 {
     return(arg != null?ModelFactory.CreateItem(editingContext, arg) : null);
 }