public void InvalidCommand(string commandName, string command, HttpResponseMessage response) { "Given I have an invalid command" .Given(() => { commandName = "ValidatedCommand"; command = "{A:0,B:0}"; }); "When I issue an HTTP request" .When(() => { response = Server.PutCommand("/commands", commandName, command); }); "Then the command should not be handled" .Then(() => { HasExecuted(commandName).Should().BeFalse(); }); "And I should get a Bad Request response" .And(() => { response.StatusCode.Should().Be(HttpStatusCode.BadRequest); }); "And the response body should contain the validation errors" .And(() => { var body = response.BodyAs<Dictionary<string, string[]>>(); body.Should().NotBeNull(); body.Should().ContainKeys("a", "b"); }); }