main
 1using developwithpassion.bdd.contexts;
 2using Gorilla.Commons.Testing;
 3using gorilla.commons.utility;
 4
 5namespace MoMoney.Presentation.Winforms.Helpers
 6{
 7    public class BindableTextBoxSpecs
 8    {
 9        [Concern(typeof (BindableTextBox<>))]
10        public class concerns_for_text_box : concerns_for<IBindableTextBox<string>, BindableTextBox<string>>
11        {
12            context c = () =>
13            {
14                control = the_dependency<ITextControl<string>>();
15            };
16
17            static protected ITextControl<string> control;
18        }
19
20        [Concern(typeof (BindableTextBox<>))]
21        public class when_binding_an_item_to_a_textbox : concerns_for_text_box
22        {
23            it should_change_the_text_of_the_text_control = () => control.was_told_to(x => x.set_selected_item("shrek"));
24
25            because b = () => sut.bind_to("shrek");
26        }
27
28        [Concern(typeof (BindableTextBox<>))]
29        public class when_getting_the_current_value_of_a_text_box : concerns_for_text_box
30        {
31            it should_return_the_current_value_of_the_text_box = () => result.should_be_equal_to("popeye");
32
33            context c = () => when_the(control).is_told_to(x => x.get_selected_item()).it_will_return("popeye");
34
35            because b = () =>
36            {
37                result = sut.get_selected_value();
38            };
39
40            static string result;
41        }
42
43        [Concern(typeof (BindableTextBox<>))]
44        public class when_an_action_needs_to_be_performed_when_the_value_of_a_textbox_changes : concerns_for_text_box
45        {
46            it should_perform_that_action = () => action.was_told_to(x => x.run());
47
48            context c = () =>
49            {
50                action = an<Command>();
51            };
52
53            because b = () =>
54            {
55                sut.on_leave(x => action.run());
56                control.when_text_is_changed();
57            };
58
59            static Command action;
60        }
61    }
62}