Esempio n. 1
0
        public void DeserializeToHandlerMessage()
        {
            var instance = new HandlerClass();

            Deserializer <HandlerClass> .InvokeMethodFromMessage(instance, Setup.Correct);

            Assert.True(instance.Invoked);
        }
Esempio n. 2
0
        public void NonExistantMethod()
        {
            var instance = new HandlerClass();

            Assert.Throws <LackingMethodsException>(() => Deserializer <HandlerClass> .InvokeMethodFromItem(instance, new NonExistant {
                AAA = "roses are red, violets are blue, this is a string comment, woopdy doo"
            }));
        }
Esempio n. 3
0
        public void DeserializesToHandlerTestMessage()
        {
            var instance = new HandlerClass();

            Deserializer <HandlerClass> .InvokeMethodFromItem(instance, new TestMessage {
                PositionZeroItem = "",
                PositionOneItem  = 1337
            });

            Assert.True(instance.Invoked);
        }
Esempio n. 4
0
        public void DeserializesEnumerable()
        {
            var instance = new HandlerClass();

            var args = new List <object>();

            var msg = Setup.Correct;

            // 4 is arbitrary here
            for (var i = 0; i < 4; i++)
            {
                msg.Arguments[1] = i;
                args.AddRange(msg.Arguments);
            }

            Assert.True(Decorator.Deserializer.TryDeserializeItems <TestMessage>(new BasicMessage("test", args.ToArray()), out var _));
        }
Esempio n. 5
0
        public void DoesntDeserializesNonEnumerable()
        {
            var instance = new HandlerClass();

            var args = new List <object>();

            var msg = Setup.NonRepeatable;

            // 4 is arbitrary here
            for (var i = 0; i < 4; i++)
            {
                msg.Arguments[0] = i;
                args.AddRange(msg.Arguments);
            }

            var t = args.ToArray();

            Assert.False(Decorator.Deserializer.TryDeserializeItems <NonRepeatable>(new BasicMessage("rep", t), out var _));
        }
Esempio n. 6
0
        public void DeserializesAndInvokesIEnumerable()
        {
            var instance = new HandlerClass();

            var args = new List <object>();

            var msg = Setup.Correct;

            // 4 is arbitrary here
            for (var i = 0; i < 4; i++)
            {
                msg.Arguments[1] = i;
                args.AddRange(msg.Arguments);
            }

            Deserializer <HandlerClass> .InvokeMethodFromMessage(instance, new BasicMessage("test", args.ToArray()));

            Assert.True(instance.Invoked);
            Assert.Equal(4, instance.Items);
        }