main
1using System.Windows.Forms;
2using developwithpassion.bdd.contexts;
3using Gorilla.Commons.Testing;
4using gorilla.commons.utility;
5
6namespace MoMoney.Presentation.Model.Navigation
7{
8 [Concern(typeof (NavigationTreeVisitor))]
9 public abstract class behaves_like_a_navigation_tree_visitor :
10 concerns_for<INavigationTreeVisitor, NavigationTreeVisitor>
11 {
12 context c = () =>
13 {
14 factory = the_dependency<ITreeViewToRootNodeMapper>();
15 registry = the_dependency<Registry<IBranchVisitor>>();
16 };
17
18 static protected ITreeViewToRootNodeMapper factory;
19 static protected Registry<IBranchVisitor> registry;
20 }
21
22 public class when_visiting_the_navigation_tree : behaves_like_a_navigation_tree_visitor
23 {
24 it should_visit_each_of_the_tree_node_visitors = () =>
25 {
26 root_node.was_told_to(x => x.accept(first_visitor));
27 root_node.was_told_to(x => x.accept(second_visitor));
28 };
29
30 context c =
31 () =>
32 {
33 tree_view = dependency<TreeView>();
34 root_node = an<ITreeBranch>();
35 first_visitor = an<IBranchVisitor>();
36 second_visitor = an<IBranchVisitor>();
37
38 when_the(factory).is_told_to(x => x.map_from(tree_view)).it_will_return(root_node);
39 when_the(registry).is_told_to(x => x.all()).it_will_return(first_visitor, second_visitor);
40 };
41
42 because b = () => sut.visit(tree_view);
43
44 static TreeView tree_view;
45 static ITreeBranch root_node;
46 static IBranchVisitor first_visitor;
47 static IBranchVisitor second_visitor;
48 }
49}