Exemplo n.º 1
0
        public void RuleConfigurationControllerShouldDisplayRules()
        {
            IList <IRule> ruleList = new List <IRule>();

            IRuleTreeView          ruleTreeView = Mocker.DynamicMock <IRuleTreeView>();
            IRuleConfigurationView view         = Mocker.DynamicMock <IRuleConfigurationView>();
            ICalidusRuleProvider   provider     = Mocker.DynamicMock <ICalidusRuleProvider>();

            Expect.Call(view.RuleTreeView).Return(ruleTreeView).Repeat.Any();
            Expect.Call(provider.GetRules(_configFactory)).IgnoreArguments().Return(ruleList).Repeat.Once();
            Expect.Call(() => view.DisplayRules(ruleList)).Repeat.Once();

            Mocker.ReplayAll();

            RuleConfigurationController controller = new RuleConfigurationController(view, provider, _configFactory);

            Mocker.VerifyAll();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a new instance of this class
        /// </summary>
        /// <param name="view">The view to use</param>
        /// <param name="provider">The rule provider to use</param>
        /// <param name="configFactory">The configuration factory to use</param>
        public RuleConfigurationController(IRuleConfigurationView view, ICalidusRuleProvider provider, ICalidusRuleConfigurationFactory configFactory)
        {
            HasChanges = false;

            _configFactory = configFactory;

            _provider = provider;

            _view = view;
            _view.RuleTreeView.BeforeRuleSelectionChanged += new EventHandler <RuleChangeCancelEventArgs>(RuleTreeView_BeforeRuleSelectionChanged);
            _view.RuleTreeView.RuleSelectionChanged       += new EventHandler <RuleEventArgs>(RuleTreeView_RuleSelectionChanged);
            _view.SelectedRuleParameterChanged            += new EventHandler <RuleConfigurationParameterEventArgs>(_view_SelectedRuleParameterChanged);
            _view.RuleParameterSettingsChanged            += new EventHandler <EventArgs>(_view_RuleParameterSettingsChanged);
            _view.Save    += new EventHandler <RuleConfigurationChangeCommandEventArgs>(_view_Save);
            _view.Closing += new EventHandler <RuleChangeCancelEventArgs>(_view_Closing);

            IEnumerable <IRule> rules = _provider.GetRules(_configFactory);

            _view.DisplayRules(rules);
        }