public void BindEventHandlerConstructor()
        {
            Type serviceType = typeof(String);
            var  bindCommand = new BindCommandIoc(serviceType);

            Assert.Equal(serviceType, bindCommand.ServiceType);
        }
        public void BindEventHandlerConstructor()
        {
            Type serviceType = typeof(String);
            var  bindCommand = new BindCommandIoc(serviceType);

            Assert.AreEqual(serviceType, bindCommand.ServiceType, "BindCommandIoc parameterized constructor fail");
        }
        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 BindCommandIocByTypeAndServiceKey()
        {
            var stubServiceProvider = MockServiceProvider.Instance;

            Type ss = typeof(_TestBindCommandIoc);
            // just use one of the test cases for BindCommandBase
            var bindCommand = new BindCommandIoc
            {
                ServiceType                    = "_TestBindCommandIoc",
                ServiceKey                     = "ServiceKey",
                ExecuteMethodName              = "ExecuteMethod",
                CanExecuteMethodName           = "CanExecuteMethod",
                EventToInvokeCanExecuteChanged = "EventHandlerNotifyCanExecuteChanged"
            };

            var bindResolve                = bindCommand.ProvideValue(stubServiceProvider);
            var fakeTargetICommand         = (ICommand)bindResolve;
            _TestBindCommandIoc _viewModel = _testList[_testList.Count - 1];

            if (fakeTargetICommand != null)
            {
                fakeTargetICommand.Execute(null);
            }
            Assert.Equal(_viewModel.ExecuteCalled, true);

            if (fakeTargetICommand != null)
            {
                fakeTargetICommand.CanExecute(null);
            }
            Assert.Equal(_viewModel.CanExecuteCalled, true);

            if (fakeTargetICommand != null)
            {
                fakeTargetICommand.CanExecuteChanged += EventHandlerCanExecuteChanged;
            }
            _count = 0;
            // Execute notification
            _viewModel.ExecuteEventNotifyCanExecuteChanged();
            Assert.Equal(_count, 1);

            // Execute notification
            if (_viewModel.DelegateNotifyCanExecuteChanged != null)
            {
                _viewModel.DelegateNotifyCanExecuteChanged();
                Assert.Equal(_count, 2);
            }
        }