main
1using developwithpassion.bdd.contexts;
2using Gorilla.Commons.Testing;
3using gorilla.commons.utility;
4using MoMoney.Service.Infrastructure.Threading;
5
6namespace momoney.service.infrastructure.threading
7{
8 [Concern(typeof (SynchronousCommandProcessor))]
9 public abstract class behaves_like_a_command_processor : concerns_for<CommandProcessor, SynchronousCommandProcessor> {}
10
11 [Concern(typeof (SynchronousCommandProcessor))]
12 public class when_running_all_the_queued_commands_waiting_for_execution : behaves_like_a_command_processor
13 {
14 it should_run_the_first_command_in_the_queue = () => first_command.was_told_to(f => f.run());
15
16 it should_run_the_second_command_in_the_queue = () => second_command.was_told_to(f => f.run());
17
18 context c = () =>
19 {
20 first_command = an<Command>();
21 second_command = an<Command>();
22 };
23
24 because b = () =>
25 {
26 sut.add(first_command);
27 sut.add(second_command);
28 sut.run();
29 };
30
31 static Command first_command;
32 static Command second_command;
33 }
34
35 [Concern(typeof (SynchronousCommandProcessor))]
36 public class when_attempting_to_rerun_the_command_processor : behaves_like_a_command_processor
37 {
38 it should_not_re_run_the_commands_that_have_already_executed =
39 () => first_command.was_told_to(f => f.run()).only_once();
40
41 context c = () =>
42 {
43 first_command = an<Command>();
44 };
45
46 because b = () =>
47 {
48 sut.add(first_command);
49 sut.run();
50 sut.run();
51 };
52
53 static Command first_command;
54 }
55}