public RuleConfigurationWindow(ICalidusProjectModel project, ICalidusProjectManager manager) { InitializeComponent(); _provider = new CalidusRuleProvider(); _configurationFactory = new CalidusRuleConfigurationFactory(project, manager); RuleConfigurationController controller = new RuleConfigurationController(ruleConfigurationView, _provider, _configurationFactory); }
public void RuleConfigurationControllerClearRuleConfigurationOnRuleSelectionChangedWithNullRule() { Expect.Call(() => _view.ClearRuleConfiguration()).Repeat.Once(); Mocker.ReplayAll(); RuleConfigurationController controller = new RuleConfigurationController(_view, _provider, _configFactory); _view.RuleTreeView.Raise(x => x.RuleSelectionChanged += null, this, new RuleEventArgs(null)); Mocker.VerifyAll(); }
public void RuleConfigurationControllerShouldNotCancelBeforeSelectionChangedIfNoChanges() { RuleChangeCancelEventArgs cancelArgs = new RuleChangeCancelEventArgs(); Mocker.ReplayAll(); RuleConfigurationController controller = new RuleConfigurationController(_view, _provider, _configFactory); _view.RuleTreeView.Raise(x => x.BeforeRuleSelectionChanged += null, this, cancelArgs); Assert.IsFalse(cancelArgs.Cancel); Mocker.VerifyAll(); }
public void RuleConfigurationControllerShouldNotDisplayRuleConfigurationParameterOnSelectedRuleParameterChangedIfParameterIsNull() { IRuleConfigurationParameter config = Mocker.DynamicMock <IRuleConfigurationParameter>(); Expect.Call(() => _view.DisplayRuleConfigurationParameter(config)).Repeat.Never(); Mocker.ReplayAll(); RuleConfigurationController controller = new RuleConfigurationController(_view, _provider, _configFactory); _view.Raise(x => x.SelectedRuleParameterChanged += null, this, new RuleConfigurationParameterEventArgs(null)); Mocker.VerifyAll(); }
public void RuleConfigurationControllerShouldGetAndDisplayRuleConfigurationOnRuleSelectionChanged() { IRule rule = Mocker.DynamicMock <IRule>(); IRuleConfiguration ruleConfig = Mocker.DynamicMock <IRuleConfiguration>(); Expect.Call(_configFactory.GetRuleConfigurationFor(rule.GetType())).Return(ruleConfig).Repeat.Once(); Expect.Call(() => _view.DisplayRuleConfiguration(ruleConfig)).Repeat.Once(); Mocker.ReplayAll(); RuleConfigurationController controller = new RuleConfigurationController(_view, _provider, _configFactory); _view.RuleTreeView.Raise(x => x.RuleSelectionChanged += null, this, new RuleEventArgs(rule)); Mocker.VerifyAll(); }
public void RuleConfigurationControllerShouldConfirmChangeOnViewClose() { RuleChangeCancelEventArgs cancelArgs = new RuleChangeCancelEventArgs(); Expect.Call(_view.ConfirmRuleSelectionChanged()).Return(false); Mocker.ReplayAll(); RuleConfigurationController controller = new RuleConfigurationController(_view, _provider, _configFactory); //set changes _view.Raise(x => x.RuleParameterSettingsChanged += null, this, EventArgs.Empty); _view.Raise(x => x.Closing += null, this, cancelArgs); Assert.IsTrue(cancelArgs.Cancel); Mocker.VerifyAll(); }
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(); }
public void RuleConfigurationControllerShouldSetConfigurationForCurrentRuleToRuleConfigurationFactory() { IRule rule = Mocker.DynamicMock <IRule>(); IRuleConfiguration ruleConfig = Mocker.DynamicMock <IRuleConfiguration>(); IRuleConfigurationOverride overrideConfig = Mocker.DynamicMock <IRuleConfigurationOverride>(); Expect.Call(_configFactory.GetRuleConfigurationFor(rule.GetType())).Return(ruleConfig).Repeat.Once(); Expect.Call(() => _configFactory.SetRuleConfiguration(overrideConfig)).IgnoreArguments().Repeat.Once(); Mocker.ReplayAll(); RuleConfigurationController controller = new RuleConfigurationController(_view, _provider, _configFactory); _view.RuleTreeView.Raise(x => x.RuleSelectionChanged += null, this, new RuleEventArgs(rule)); _view.Raise(x => x.Save += null, this, new RuleConfigurationChangeCommandEventArgs(new Dictionary <IRuleConfigurationParameter, object>())); Mocker.VerifyAll(); }