Ejemplo n.º 1
0
        public void Create_ActionWithoutTarget_SetsMethodOnly()
        {
            var method = typeof(Console).GetMethod("WriteLine", new Type[0]);
            var result = SerializableLambda.Create(Console.WriteLine, _serializerMock.Object);

            Assert.Null(result.TargetType);
            Assert.Null(result.TargetValues);
            Assert.AreEqual(method, result.Method);
        }
Ejemplo n.º 2
0
        public void Create_ActionWithTarget_SetsTypeAndMethodAndSerializesTarget()
        {
            int    capturedInt = 42;
            Action lambda      = () => Console.WriteLine(capturedInt);

            _serializerMock
            .Setup(serializer => serializer.Serialize(lambda.Target))
            .Returns(new Dictionary <string, object>());

            var result = SerializableLambda.Create(lambda, _serializerMock.Object);

            Assert.NotNull(result.TargetType);
            Assert.AreEqual(lambda.Target.GetType(), result.TargetType);
            Assert.NotNull(result.Method);
            Assert.AreEqual(lambda.Method, result.Method);
        }