public void ImageMessageHandlerOnlyHandlesImageMessageActions()
        {
            var ddna = Substitute.For <DDNA>();
            var cbk  = Substitute.For <Action <ImageMessage> >();
            var uut  = new ImageMessageHandler(ddna, cbk);
            var t1   = Substitute.For <EventTrigger>();

            t1.GetAction().Returns("gameParameters");

            Expect(uut.Type(), Is.EqualTo("imageMessage"));
            Expect(uut.Handle(t1, store), Is.False);
            cbk.DidNotReceive().Invoke(Arg.Any <ImageMessage>());

            var t2 = Substitute.For <EventTrigger>();

            t2.GetAction().Returns("imageMessage");
            t2.GetResponse().Returns(IMAGE_MESSAGE.Json());
            var ims = Substitute.For <ImageMessageStore>();

            ddna.GetImageMessageStore().Returns(ims);
            ims.Has("url").Returns(true);

            Expect(uut.Handle(t2, store));
            cbk.Received().Invoke(Arg.Any <ImageMessage>());

            var t3 = Substitute.For <EventTrigger>();

            t3.GetAction().Returns("imageMessage");
            t3.GetResponse().Returns(IMAGE_MESSAGE.Json());
            ims.Has("url").Returns(false);

            Expect(uut.Handle(t3, store), Is.False);
            cbk.Received(1).Invoke(Arg.Any <ImageMessage>());
        }
        public void ImageMessageHandlerUsesPersistentActionAndRemovesIt()
        {
            var ddna    = Substitute.For <DDNA>();
            var cbk     = Substitute.For <Action <ImageMessage> >();
            var uut     = new ImageMessageHandler(ddna, cbk);
            var trigger = Substitute.For <EventTrigger>();

            trigger.GetAction().Returns("imageMessage");
            trigger.GetResponse().Returns(IMAGE_MESSAGE.Json());
            var persisted = "{\"b\":2}".Json();

            store.Get(trigger).Returns(persisted);
            var ims = Substitute.For <ImageMessageStore>();

            ddna.GetImageMessageStore().Returns(ims);
            ims.Has("url").Returns(true);

            Expect(uut.Handle(trigger, store));
            store.Received().Remove(Arg.Is(trigger));
            cbk.Received().Invoke(Arg.Is <ImageMessage>(e => e.Parameters == persisted));
        }