示例#1
0
        public void TestThatParameterlessExpressionInvokes()
        {
            Expression <Action <IParameterlessInterface> > expression = a => a.DoSomething();
            var serialized = ExpressionSerialization.Serialize(expression);

            var actor             = new ActorTest();
            var serializationInfo = ExpressionSerialization.Deserialize <IParameterlessInterface>(serialized);
            var consumer          = ExpressionExtensions.CreateDelegate <IParameterlessInterface>(actor, serializationInfo);

            consumer(actor);
            Assert.True(actor.WasRun);
        }
示例#2
0
        async Task <T> ExecuteImplAsync <T>(LambdaExpression expr)
        {
            var requestJson = ExpressionSerialization.Serialize(expr);

            var webClient = new WebClient();

            webClient.Headers.Add("Content-Type", "application/json");
            var resultJson = await webClient.UploadStringTaskAsync(url, requestJson);

            var result = JsonConvert.DeserializeObject <T>(resultJson);

            return(result);
        }
示例#3
0
        public void TestThatSimpleParameterExpressionInvokes()
        {
            var message = "hello";
            var i       = 10;
            Expression <Action <ISimpleParametersInterface> > expression = a => a.DoSomething(message, i);
            var serialized = ExpressionSerialization.Serialize(expression);

            var actor             = new ActorTest();
            var serializationInfo = ExpressionSerialization.Deserialize <ISimpleParametersInterface>(serialized);
            var consumer          = ExpressionExtensions.CreateDelegate <ISimpleParametersInterface>(actor, serializationInfo);

            consumer(actor);
            Assert.Equal(i, actor.Count);
            Assert.Equal(message, actor.Message);
        }
示例#4
0
        public void TestThatSimpleExpressionInvokes()
        {
            var actor = new ActorTest();
            var m     = "Test";
            Expression <Action <int> > expression = i => actor.DoSomething(m, i);
            var serialized = ExpressionSerialization.Serialize(expression);

            var serializationInfo = ExpressionSerialization.Deserialize(serialized);
            var consumer          = ExpressionExtensions.CreateDelegate <IParameterlessInterface, int>(actor, serializationInfo);

            consumer(actor, 100);

            Assert.Equal(100, actor.Count);
            Assert.Equal(m, actor.Message);
        }
示例#5
0
        public void TestThatComplexParameterExpressionInvokes()
        {
            var i = 10;
            var complexParameters = new ComplexParameters
            {
                Int             = 1,
                Message         = "Hello",
                InnerParameters = new ComplexParameters
                {
                    Int     = 2,
                    Message = "World"
                }
            };
            Expression <Action <IComplexParameterInterface> > expression = a => a.DoSomething(i, complexParameters);
            var serialized = ExpressionSerialization.Serialize(expression);

            var actor             = new ActorTest();
            var serializationInfo = ExpressionSerialization.Deserialize <IComplexParameterInterface>(serialized);
            var consumer          = ExpressionExtensions.CreateDelegate <IComplexParameterInterface>(actor, serializationInfo);

            consumer(actor);
            Assert.Equal(i, actor.Count);
            Assert.Equal(complexParameters, actor.Parameters);
        }