public void Setup() { _mapper = MockRepository.GenerateMock <IViewModelToCommandMappingEngine>(); _mockedServiceLocator = MockRepository.GenerateMock <IServiceLocator>(); _mockedServiceLocator .Stub(x => x.GetInstance <IViewModelToCommandMappingEngine>()) .Return(_mapper); ServiceLocator.SetLocatorProvider(() => _mockedServiceLocator); _commandExecutor = MockRepository.GenerateMock <ICommandExecutor>(); _viewModelFactory = MockRepository.GenerateMock <IViewModelFactory <DummyReadExecuteViewModel, DummyReadExecuteViewModelArgs> >(); _controller = new DummyReadExecuteController( _commandExecutor, _viewModelFactory); _viewModelFactory .Stub(x => x.GetViewModel()) .Return(new DummyReadExecuteViewModel()); var routeData = new RouteData(); routeData.Values.Add("controller", "DummyDeleteFile"); _controller.ControllerContext = new ControllerContext { RouteData = routeData }; }
public void Setup() { _mapper = MockRepository.GenerateMock<IViewModelToCommandMappingEngine>(); _mockedServiceLocator = MockRepository.GenerateMock<IServiceLocator>(); _mockedServiceLocator .Stub( x => x.GetInstance<IViewModelToCommandMappingEngine>() ) .Return( _mapper ); ServiceLocator.SetLocatorProvider( () => _mockedServiceLocator ); _commandExecutor = MockRepository.GenerateMock<ICommandExecutor>(); _viewModelFactory = MockRepository.GenerateMock<IViewModelFactory<DummyReadExecuteViewModel, DummyReadExecuteViewModelArgs>>(); _controller = new DummyReadExecuteController( _commandExecutor, _viewModelFactory ); _viewModelFactory .Stub( x => x.GetViewModel() ) .Return( new DummyReadExecuteViewModel() ); var routeData = new RouteData(); routeData.Values.Add( "controller", "DummyDeleteFile" ); _controller.ControllerContext = new ControllerContext { RouteData = routeData }; }
public void Setup() { _mapper = MockRepository.GenerateMock<IViewModelToCommandMappingEngine>(); _mockedServiceLocator = MockRepository.GenerateMock<IServiceLocator>(); _mockedServiceLocator .Stub( x => x.GetInstance<IViewModelToCommandMappingEngine>() ) .Return( _mapper ); ServiceLocator.SetLocatorProvider( () => _mockedServiceLocator ); _commandExecutor = MockRepository.GenerateMock<ICommandExecutor>(); _messageManager = MockRepository.GenerateMock<IMessageManager>(); _referrerProvider = MockRepository.GenerateMock<IReferrerProvider>(); _controller = new DummyExecuteController( _commandExecutor, _messageManager, _referrerProvider ); var routeData = new RouteData(); routeData.Values.Add( "controller", "DummyDeleteFile" ); _controller.ControllerContext = new ControllerContext { RouteData = routeData }; }
public static TTo Map <TFrom, TTo>(TFrom viewModel) { IViewModelToCommandMappingEngine mappingEngine = null; var serviceLocator = ServiceLocator.Current; if (serviceLocator == null) { throw new ApplicationException( "ServiceLocator is null. Did you call ServiceLocator.SetLocatorProvider( {arg} ) in application initialization code? "); } mappingEngine = ServiceLocator.Current.GetInstance <IViewModelToCommandMappingEngine>(); if (mappingEngine == null) { throw new Exception( "IViewModelToCommandMappingEngine implementation is not registered. Please register it in your initialization code."); } return(mappingEngine.Map <TFrom, TTo>(viewModel)); }
public void Setup() { _mapper = MockRepository.GenerateMock <IViewModelToCommandMappingEngine>(); _mockedServiceLocator = MockRepository.GenerateMock <IServiceLocator>(); _mockedServiceLocator .Stub(x => x.GetInstance <IViewModelToCommandMappingEngine>()) .Return(_mapper); ServiceLocator.SetLocatorProvider(() => _mockedServiceLocator); _commandExecutor = MockRepository.GenerateMock <ICommandExecutor>(); _messageManager = MockRepository.GenerateMock <IMessageManager>(); _referrerProvider = MockRepository.GenerateMock <IReferrerProvider>(); _controller = new DummyExecuteController(_commandExecutor, _messageManager, _referrerProvider); var routeData = new RouteData(); routeData.Values.Add("controller", "DummyDeleteFile"); _controller.ControllerContext = new ControllerContext { RouteData = routeData }; }