main
 1using developwithpassion.bdd.contexts;
 2using developwithpassion.bdd.harnesses.mbunit;
 3using gorilla.migrations;
 4using Rhino.Mocks;
 5
 6namespace tests.core
 7{
 8    public class CommandRegistrySpecs
 9    {
10        public class when_commands_are_registered :
11            observations_for_a_sut_with_a_contract<CommandRegistry, ConsoleArgumentsCommandRegistry>
12        {
13            context c = () =>
14                            {
15                                command = controller.an<ConsoleCommand>();
16                                correct_args = controller.an<ConsoleArguments>();
17                                command.Stub(x => x.can_handle(correct_args)).Return(true);
18                            };
19
20            after_the_sut_has_been_created a = () => { controller.sut.register(command); };
21
22            protected static ConsoleArguments correct_args;
23            protected static ConsoleCommand command;
24        }
25
26        public class when_looking_up_the_appropriate_command_for_some_console_arguments : when_commands_are_registered
27        {
28            it should_return_the_command_that_can_process_the_request = () => { result.should_be_equal_to(command); };
29
30            because b = () => { result = controller.sut.command_for(correct_args); };
31
32            static ParameterizedCommand<ConsoleArguments> result;
33        }
34
35        public class when_attempting_to_find_a_command_that_can_process_a_set_of_arguments_that_is_not_recognized :
36            when_commands_are_registered
37        {
38            it should_return_a_command_that_can_inform_the_user_of_the_error =
39                () => { result.should_be_an_instance_of<HelpCommand>(); };
40
41            because b = () => { result = controller.sut.command_for(unknown_args); };
42
43            static readonly string[] unknown_args = new[] {""};
44            static ParameterizedCommand<ConsoleArguments> result;
45        }
46    }
47}