public void CommandHandlerProxyConstructorExceptionTests() { EventInfo outerEvent = _testStubs.GetType().GetEvent("IssueNotifyExecuteButtonChanged"); UnitTestInternal.AssertThrows(typeof(ArgumentException), // ReSharper disable ObjectCreationAsStatement () => { new CommandHandlerProxy(null); }, "CommandHandlerProxy - Constructor should throw Exception"); UnitTestInternal.AssertThrows(typeof(ArgumentException), () => { new CommandHandlerProxy(_testStubs.ExecuteButton_Click_External, null, outerEvent); }, "CommandHandlerProxy - Constructor should throw Exception"); UnitTestInternal.AssertThrows(typeof(ArgumentException), () => { new CommandHandlerProxy(_testStubs.ExecuteButton_Click_External, null, outerEvent, _testStubs); }, "CommandHandlerProxy - Constructor should throw Exception"); UnitTestInternal.AssertThrows(typeof(ArgumentException), () => { new CommandHandlerProxy(_testStubs.ExecuteButton_Click_External, null, (EventInfo)null, _testStubs); }, "CommandHandlerProxy - Constructor should throw Exception"); UnitTestInternal.AssertThrows(typeof(ArgumentException), () => { new CommandHandlerProxy(null, _testStubs.CanExecuteButton_Click_External, a => _testStubs.IssueNotifyExecuteButtonChanged += a); }, "CommandHandlerProxy - Constructor should throw Exception"); UnitTestInternal.AssertThrows(typeof(ArgumentException), () => { new CommandHandlerProxy(_testStubs.ExecuteButton_Click_External, null, a => _testStubs.IssueNotifyExecuteButtonChanged += a); }, "CommandHandlerProxy - Constructor should throw Exception"); // ReSharper restore ObjectCreationAsStatement }
public void ProvideValueExceptions() { var stubServiceProvider = MockServiceProvider.Instance; var bindEvent = new BindEventHandlerIoc { ServiceType = typeof(_TestBindEventHandlerIoc) }; var provider = stubServiceProvider; // ReSharper disable ImplicitlyCapturedClosure UnitTestInternal.AssertThrows(typeof(ArgumentException), () => bindEvent.ProvideValue(provider), "ProvideValueExceptions - expected exception - ArgumentException"); // ReSharper restore ImplicitlyCapturedClosure bindEvent.PropertyName = "ButtonClickPropDelegate"; bindEvent.MethodName = "ButtonClick"; // ReSharper disable ImplicitlyCapturedClosure UnitTestInternal.AssertThrows(typeof(ArgumentException), () => bindEvent.ProvideValue(provider), // ReSharper restore ImplicitlyCapturedClosure "ProvideValueExceptions - expected exception - ArgumentException"); bindEvent.PropertyName = null; bindEvent.MethodName = null; stubServiceProvider = MockServiceProvider.Instance; // ReSharper disable ImplicitlyCapturedClosure UnitTestInternal.AssertThrows(typeof(ArgumentException), () => bindEvent.ProvideValue(stubServiceProvider), "ProvideValueExceptions - expected exception - ArgumentException"); // ReSharper restore ImplicitlyCapturedClosure }
public void ProvideValueExceptions() { var stubServiceProvider = MockServiceProvider.Instance; var bindEvent = new BindEventHandler(); var viewModel = new _TestBindEventHandler(); bindEvent.Source = viewModel; // ReSharper disable AccessToModifiedClosure UnitTestInternal.AssertThrows(typeof(ArgumentException), () => bindEvent.ProvideValue(stubServiceProvider), // ReSharper restore AccessToModifiedClosure "ProvideValueExceptions - expected exception - ArgumentException"); bindEvent.PropertyName = "ButtonClickPropDelegate"; bindEvent.MethodName = "ButtonClick"; // ReSharper disable AccessToModifiedClosure UnitTestInternal.AssertThrows(typeof(ArgumentException), () => bindEvent.ProvideValue(stubServiceProvider), // ReSharper restore AccessToModifiedClosure "ProvideValueExceptions - expected exception - ArgumentException"); bindEvent.PropertyName = null; bindEvent.MethodName = null; stubServiceProvider = MockServiceProvider.Instance; UnitTestInternal.AssertThrows(typeof(ArgumentException), () => bindEvent.ProvideValue(stubServiceProvider), "ProvideValueExceptions - expected exception - ArgumentException"); }
public void TestMethodIocBindingException() { var iocBinding = new IocBinding(); // ReSharper disable AssignNullToNotNullAttribute UnitTestInternal.AssertThrows(typeof(ArgumentNullException), () => iocBinding.ProvideValue(null), " IocBinding - expected ArgumentNullException"); // ReSharper restore AssignNullToNotNullAttribute }
public void BindCommandIocExceptions() { var stubServiceProvider = MockServiceProvider.Instance; var bindCommand = new BindCommandIoc { ExecuteMethodName = "_ExecuteMethod", CanExecuteMethodName = "CanExecuteMethod", EventToInvokeCanExecuteChanged = "EventHandlerNotifyCanExecuteChanged", }; UnitTestInternal.AssertThrows(typeof(ArgumentNullException), () => bindCommand.ProvideValue(stubServiceProvider), "ProvideValueExceptions - expected exception - ArgumentNullException"); bindCommand = new BindCommandIoc { ServiceKey = "ServiceKey", ExecuteMethodName = "_ExecuteMethod", CanExecuteMethodName = "CanExecuteMethod", EventToInvokeCanExecuteChanged = "EventHandlerNotifyCanExecuteChanged", }; UnitTestInternal.AssertThrows(typeof(ArgumentNullException), () => bindCommand.ProvideValue(stubServiceProvider), "ProvideValueExceptions - expected exception - ArgumentNullException"); bindCommand = new BindCommandIoc { ServiceType = "ABRACADABRA", ServiceKey = "ServiceKey", ExecuteMethodName = "_ExecuteMethod", CanExecuteMethodName = "CanExecuteMethod", EventToInvokeCanExecuteChanged = "EventHandlerNotifyCanExecuteChanged", }; UnitTestInternal.AssertThrows(typeof(InvalidOperationException), () => bindCommand.ProvideValue(stubServiceProvider), "ProvideValueExceptions - expected exception - InvalidOperationException"); bindCommand = new BindCommandIoc { ServiceType = typeof(_TestBindCommandIoc), ServiceKey = "ABRACADABRA", ExecuteMethodName = "_ExecuteMethod", CanExecuteMethodName = "CanExecuteMethod", EventToInvokeCanExecuteChanged = "EventHandlerNotifyCanExecuteChanged", }; UnitTestInternal.AssertThrows(typeof(ArgumentException), () => bindCommand.ProvideValue(stubServiceProvider), "ProvideValueExceptions - expected exception - ArgumentException"); }
public void StaticCommandHandlerProxyConstructorExceptionTests() { EventInfo outerEvent = typeof(StaticCommandEventStubs).GetEvent("IssueNotifyExecuteButtonChanged"); UnitTestInternal.AssertThrows(typeof(ArgumentException), // ReSharper disable ObjectCreationAsStatement () => { new WeakCommandHandlerProxy(null); }, // ReSharper restore ObjectCreationAsStatement "WeakCommandHandlerProxy - Constructor should throw Exception"); UnitTestInternal.AssertThrows(typeof(ArgumentException), // ReSharper disable ObjectCreationAsStatement // ReSharper disable ImplicitlyCapturedClosure () => { new WeakCommandHandlerProxy(StaticCommandEventStubs.ExecuteButton_Click_External, null, outerEvent); }, // ReSharper restore ImplicitlyCapturedClosure // ReSharper restore ObjectCreationAsStatement "WeakCommandHandlerProxy - Constructor should throw Exception"); UnitTestInternal.AssertThrows(typeof(ArgumentException), // ReSharper disable ObjectCreationAsStatement () => { new WeakCommandHandlerProxy(StaticCommandEventStubs.ExecuteButton_Click_External, null, outerEvent, _testStubs); }, // ReSharper restore ObjectCreationAsStatement "WeakCommandHandlerProxy - Constructor should throw Exception"); UnitTestInternal.AssertThrows(typeof(ArgumentException), // ReSharper disable ObjectCreationAsStatement () => { new WeakCommandHandlerProxy(StaticCommandEventStubs.ExecuteButton_Click_External, null, (EventInfo)null, _testStubs); }, // ReSharper restore ObjectCreationAsStatement "WeakCommandHandlerProxy - Constructor should throw Exception"); UnitTestInternal.AssertThrows(typeof(ArgumentException), // ReSharper disable ObjectCreationAsStatement () => { new WeakCommandHandlerProxy(null, StaticCommandEventStubs.CanExecuteButton_Click_External, a => StaticCommandEventStubs.IssueNotifyExecuteButtonChanged += a); }, // ReSharper restore ObjectCreationAsStatement "WeakCommandHandlerProxy - Constructor should throw Exception"); UnitTestInternal.AssertThrows <ArgumentException>( // ReSharper disable ObjectCreationAsStatement () => { new WeakCommandHandlerProxy(StaticCommandEventStubs.ExecuteButton_Click_External, null, a => StaticCommandEventStubs.IssueNotifyExecuteButtonChanged += a); }, // ReSharper restore ObjectCreationAsStatement "WeakCommandHandlerProxy - Constructor should throw Exception"); }
public void ProvideValueFromSourceExceptions() { var stubServiceProvider = MockServiceProvider.Instance; var bindCommand = new BindCommand(); var viewModel = new _TestBindCommand(); bindCommand.Source = viewModel; bindCommand.ExecuteMethodName = "_ExecuteMethod"; bindCommand.CanExecuteMethodName = "CanExecuteMethod"; bindCommand.EventToInvokeCanExecuteChanged = "EventNotifyCanExecuteChanged"; bindCommand.PropertyActionCanExecuteChanged = "DelegateNotifyCanExecuteChanged"; UnitTestInternal.AssertThrows(typeof(ArgumentException), () => bindCommand.ProvideValue(stubServiceProvider), "ProvideValueExceptions - expected exception - ArgumentException"); bindCommand.ExecuteMethodName = "ExecuteMethod"; bindCommand.CanExecuteMethodName = "_CanExecuteMethod"; bindCommand.EventToInvokeCanExecuteChanged = "EventNotifyCanExecuteChanged"; bindCommand.PropertyActionCanExecuteChanged = "DelegateNotifyCanExecuteChanged"; UnitTestInternal.AssertThrows(typeof(ArgumentException), () => bindCommand.ProvideValue(stubServiceProvider), "ProvideValueExceptions - expected exception - ArgumentException"); bindCommand.ExecuteMethodName = "ExecuteMethod"; bindCommand.CanExecuteMethodName = "CanExecuteMethod"; bindCommand.EventToInvokeCanExecuteChanged = "_EventNotifyCanExecuteChanged"; bindCommand.PropertyActionCanExecuteChanged = "DelegateNotifyCanExecuteChanged"; UnitTestInternal.AssertThrows(typeof(ArgumentException), () => bindCommand.ProvideValue(stubServiceProvider), "ProvideValueExceptions - expected exception - ArgumentException"); bindCommand.ExecuteMethodName = "ExecuteMethod"; bindCommand.CanExecuteMethodName = "CanExecuteMethod"; bindCommand.EventToInvokeCanExecuteChanged = "EventNotifyCanExecuteChanged"; bindCommand.PropertyActionCanExecuteChanged = "_DelegateNotifyCanExecuteChanged"; UnitTestInternal.AssertThrows(typeof(ArgumentException), () => bindCommand.ProvideValue(stubServiceProvider), "ProvideValueExceptions - expected exception - ArgumentException"); }