main
1using System;
2using System.Linq.Expressions;
3using developwithpassion.bdd.contexts;
4using Gorilla.Commons.Testing;
5
6namespace MoMoney.Presentation.Winforms.Databinding
7{
8 public class BindingSelectorSpecs
9 {
10 }
11
12 [Concern(typeof (BindingSelector<>))]
13 public class when_selecting_a_property_as_the_target_of_a_binding : concerns_for<IBindingSelector<IAnInterface>>
14 {
15 it should_return_a_binder_bound_to_the_correct_property =
16 () => result.property.Name.should_be_equal_to("FirstName");
17
18 it should_inspect_the_expression_for_the_property_information =
19 () => inspector.was_told_to(i => i.inspect(expression_to_parse));
20
21 context c = () =>
22 {
23 thing_to_bind_to = an<IAnInterface>();
24 factory = an<IPropertyInspectorFactory>();
25 inspector = an<IPropertyInspector<IAnInterface, string>>();
26
27 factory.is_told_to(f => f.create<IAnInterface, string>()).it_will_return(inspector);
28
29 inspector.is_told_to(i => i.inspect(null))
30 .IgnoreArguments().it_will_return(typeof (IAnInterface).GetProperty("FirstName"));
31 };
32
33 because b = () =>
34 {
35 expression_to_parse = (s => s.FirstName);
36 result = sut.bind_to_property(expression_to_parse);
37 };
38
39 public override IBindingSelector<IAnInterface> create_sut()
40 {
41 return new BindingSelector<IAnInterface>(thing_to_bind_to, factory);
42 }
43
44 static IAnInterface thing_to_bind_to;
45 static IPropertyBinder<IAnInterface, string> result;
46 static IPropertyInspectorFactory factory;
47 static IPropertyInspector<IAnInterface, string> inspector;
48 static Expression<Func<IAnInterface, string>> expression_to_parse;
49 }
50}