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 calls_to_the_handler_if_one_matches_the_json() { var message = new RunSpec { id = "foo" }; var json = JsonSerialization.ToCleanJson(message); theConnector.HandleJson(json); theCommand.Received.Single() .id.ShouldBe("foo"); theRemoteController.DidNotReceive().SendJsonMessage(json); }
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); }
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" }; ClassUnderTest.HandleMessage(theMessage); MockFor <IRemoteController>().Received().SendMessage(theMessage); // *do* auto-save MockFor <IPersistenceController>().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" }; ClassUnderTest.HandleMessage(theMessage); MockFor <IRemoteController>().Received().SendMessage(theMessage); // do not auto-save MockFor <IPersistenceController>().DidNotReceive().SaveSpecification("foo", theSpecSentFromTheClient); }
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_by_id_only() { var theSpecRetrievedFromPersistence = new Specification(); MockFor <IPersistenceController>().LoadSpecification("foo") .Returns(new SpecData { data = theSpecRetrievedFromPersistence }); var theMessage = new RunSpec { id = "foo" }; ClassUnderTest.HandleMessage(theMessage); MockFor <IRemoteController>().Received().SendMessage(theMessage); theMessage.spec.ShouldBeTheSameAs(theSpecRetrievedFromPersistence); }