main
1using System.Collections.Generic;
2using developwithpassion.bdd.contexts;
3using Gorilla.Commons.Testing;
4
5namespace MoMoney.Presentation.Winforms.Helpers
6{
7 public class BindableListBoxSpecs
8 {
9 }
10
11 [Concern(typeof(BindableListBox<>))]
12 public class behaves_like_bindable_list : concerns_for<IBindableList<string>, BindableListBox<string>>
13 {
14 context c = () => { control = the_dependency<IListControl<string>>(); };
15
16 static protected IListControl<string> control;
17 }
18
19 [Concern(typeof(BindableListBox<>))]
20 public class when_binding_a_bunch_of_items_to_a_list_control : behaves_like_bindable_list
21 {
22 it should_add_each_item_to_the_list_control = () =>
23 {
24 control.was_told_to(x => x.add_item("timone"));
25 control.was_told_to(x => x.add_item("pumba"));
26 };
27
28 because b = () => sut.bind_to(new List<string> {"timone", "pumba",});
29 }
30
31 [Concern(typeof(BindableListBox<>))]
32 public class when_assigning_the_selected_item_of_a_list_control : behaves_like_bindable_list
33 {
34 it should_tell_the_list_control_to_select_that_item =
35 () => control.was_told_to(x => x.set_selected_item("arthur"));
36
37 because b = () => sut.set_selected_item("arthur");
38 }
39
40 [Concern(typeof(BindableListBox<>))]
41 public class when_getting_the_selected_item_from_a_list_control : behaves_like_bindable_list
42 {
43 it should_return_the_selected_item = () => result.should_be_equal_to("curious george");
44 context c = () => when_the(control).is_told_to(x => x.get_selected_item()).it_will_return("curious george");
45 because b = () => { result = sut.get_selected_item(); };
46
47 static string result;
48 }
49}