Ejemplo n.º 1
0
        public BaseReadExecuteControllerTests()
        {
            _mapperMock          = new Mock <IViewModelToCommandMappingEngine>();
            _serviceProviderMock = new Mock <IServiceProvider>();
            _serviceProviderMock
            .Setup(x => x.GetService(typeof(IViewModelToCommandMappingEngine)))
            .Returns(_mapperMock);

            _commandExecutor      = new Mock <ICommandExecutor>();
            _viewModelFactoryMock = new Mock <IViewModelFactory <DummyReadExecuteViewModel, DummyReadExecuteViewModelArgs> >();

            _controller = ControllerInstantiater.Instantiate <DummyReadExecuteController>(
                _commandExecutor.Object,
                _mapperMock.Object,
                _viewModelFactoryMock.Object);

            _viewModelFactoryMock
            .Setup(x => x.GetViewModel())
            .Returns(new DummyReadExecuteViewModel());

            var routeData = new RouteData();

            routeData.Values.Add("controller", "DummyDeleteFile");
            _controller.ControllerContext.RouteData = routeData;

            var objectValidator = new Mock <IObjectModelValidator>();

            objectValidator.Setup(o => o.Validate(It.IsAny <ActionContext>(),
                                                  It.IsAny <ValidationStateDictionary>(),
                                                  It.IsAny <string>(),
                                                  It.IsAny <Object>()));
            _controller.ObjectValidator = objectValidator.Object;

            _controller.TempData = new TempDataDictionary(new Mock <HttpContext>().Object, new Mock <ITempDataProvider>().Object);
        }
Ejemplo n.º 2
0
 public BaseExecuteControllerTests()
 {
     _commandExecutorMock  = new Mock <ICommandExecutor>();
     _mappingEngineMock    = new Mock <IViewModelToCommandMappingEngine>();
     _messageManagerMock   = new Mock <IMessageManager>();
     _referrerProviderMock = new Mock <IReferrerProvider>();
     _controller           = ControllerInstantiater.Instantiate <DummyExecuteController>(_commandExecutorMock.Object, _mappingEngineMock.Object, _messageManagerMock.Object, _referrerProviderMock.Object);
 }
Ejemplo n.º 3
0
        public BaseReadControllerTests()
        {
            _viewModelFactoryMock = new Mock <IViewModelFactory <DummyReadViewModel, DummyReadViewModelProviderArgument> >();
            _controller           = ControllerInstantiater.Instantiate <DummyReadController>(_viewModelFactoryMock.Object);

            var routeData = new RouteData();

            routeData.Values.Add("controller", "DummyDeleteFile");
            _controller.ControllerContext.RouteData = routeData;
            _controller.TempData = new TempDataDictionary(_controller.HttpContext, new Mock <ITempDataProvider>().Object);
        }
Ejemplo n.º 4
0
        public void HasSetAllDependencies()
        {
            var viewModelFactory = new Mock <IViewModelFactory <DummyReadViewModel, DummyReadViewModelProviderArgument> >();
            var locator          = new Mock <IServiceProvider>();

            locator
            .Setup(x => x.GetService(typeof(IViewModelFactory <DummyReadViewModel, DummyReadViewModelProviderArgument>)))
            .Returns(viewModelFactory);

            var controller = ControllerInstantiater.Instantiate <DummyReadController>(_viewModelFactoryMock.Object);

            HasSetAllDependenciesControllerHelper.AssertFieldsAreNotNull(controller);
        }
        public void HasSetAllDependencies()
        {
            var commandExecutor = new Mock <ICommandExecutor>();

            var locator = new Mock <IServiceProvider>();

            locator
            .Setup(x => x.GetService(typeof(ICommandExecutor)))
            .Returns(commandExecutor);

            var controller = ControllerInstantiater.Instantiate <DummyCommandController>(_commandExecutorMock.Object, _mapperMock.Object);

            HasSetAllDependenciesControllerHelper.AssertFieldsAreNotNull(controller);
        }
        public BaseCommandControllerTests()
        {
            _mapperMock = new Mock <IViewModelToCommandMappingEngine>();

            _commandExecutorMock  = new Mock <ICommandExecutor>();
            _messageManagerMock   = new Mock <IMessageManager>();
            _referrerProviderMock = new Mock <IReferrerProvider>();
            _controller           = ControllerInstantiater.Instantiate <DummyExecuteController>(_commandExecutorMock.Object, _mapperMock.Object, _messageManagerMock.Object, _referrerProviderMock.Object);

            var routeData = new RouteData();

            routeData.Values.Add("controller", "DummyDeleteFile");
            _controller.ControllerContext = new ControllerContext
            {
                RouteData = routeData
            };
        }
Ejemplo n.º 7
0
        public void HasSetAllDependencies()
        {
            var viewModelFactory = new Mock <IViewModelFactory <DummyReadExecuteViewModel, DummyReadExecuteViewModelArgs> >();
            var commandExecutor  = new Mock <ICommandExecutor>();
            var locator          = new Mock <IServiceProvider>();

            locator
            .Setup(x => x.GetService(typeof(IViewModelFactory <DummyReadExecuteViewModel, DummyReadExecuteViewModelArgs>)))
            .Returns(viewModelFactory);

            locator
            .Setup(x => x.GetService(typeof(ICommandExecutor)))
            .Returns(commandExecutor);

            var controller = ControllerInstantiater.Instantiate <DummyReadExecuteController>(_commandExecutor.Object, _mapperMock.Object, viewModelFactory.Object);

            HasSetAllDependenciesControllerHelper.AssertFieldsAreNotNull(controller);
        }
Ejemplo n.º 8
0
        public void HasSetAllDependencies()
        {
            var messageManager   = new Mock <IMessageManager>();
            var commandExecutor  = new Mock <ICommandExecutor>();
            var referrerProvider = new Mock <IReferrerProvider>();

            var locator = new Mock <IServiceProvider>();

            locator
            .Setup(x => x.GetService(typeof(ICommandExecutor)))
            .Returns(commandExecutor);
            locator
            .Setup(x => x.GetService(typeof(IMessageManager)))
            .Returns(messageManager);
            locator
            .Setup(x => x.GetService(typeof(IReferrerProvider)))
            .Returns(referrerProvider);

            var controller = ControllerInstantiater.Instantiate <DummyExecuteController>(commandExecutor.Object, _mappingEngineMock.Object, messageManager.Object, referrerProvider.Object);

            HasSetAllDependenciesControllerHelper.AssertFieldsAreNotNull(controller);
        }