Inheritance: ClientMessage
        public void can_pick_up_the_type_of_a_client_message_from_the_json_bodyy()
        {
            var message = new RunSpec {id = "embeds"};
            var json = JsonSerialization.ToCleanJson(message);

            var deserialized = JsonSerialization.DeserializeMessage(json)
                .ShouldBeOfType<RunSpec>();

            deserialized.id.ShouldBe("embeds");
            deserialized.ShouldNotBeTheSameAs(message);
        }
        public void run_spec_by_id_only()
        {
            var theSpecRetrievedFromPersistence = new Specification();

            app.Persistence.LoadSpecification("foo")
                .Returns(new SpecData
                {
                    data = theSpecRetrievedFromPersistence
                });

            var theMessage = new RunSpec{id = "foo"};
            new RunSpecCommand().HandleMessage(theMessage, app);

            app.Engine.Received().SendMessage(theMessage);

            theMessage.spec.ShouldBeTheSameAs(theSpecRetrievedFromPersistence);
        }
        public void run_spec_with_body_and_revision_denoting_auto_save()
        {
            var theSpecSentFromTheClient = new Specification();

            var theMessage = new RunSpec
            {
                revision = Guid.NewGuid().ToString(),
                spec = theSpecSentFromTheClient,
                id = "foo"
            };

            new RunSpecCommand().HandleMessage(theMessage, app);

            app.Engine.Received().SendMessage(theMessage);

            // *do* auto-save
            app.Persistence.Received().SaveSpecification("foo", theSpecSentFromTheClient);

        }
        public void run_spec_with_body_but_no_revision()
        {
            var theSpecSentFromTheClient = new Specification();

            var theMessage = new RunSpec
            {
                revision = null,
                spec = theSpecSentFromTheClient,
                id = "foo"
            };

            new RunSpecCommand().HandleMessage(theMessage, app);

            app.Engine.Received().SendMessage(theMessage);

            // do not auto-save
            app.Persistence.DidNotReceive().SaveSpecification("foo", theSpecSentFromTheClient);

        }