예제 #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
        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);
        }
예제 #3
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);
        }