当前位置: 首页>>代码示例>>C#>>正文


C# IServiceLocator.Stub方法代码示例

本文整理汇总了C#中IServiceLocator.Stub方法的典型用法代码示例。如果您正苦于以下问题:C# IServiceLocator.Stub方法的具体用法?C# IServiceLocator.Stub怎么用?C# IServiceLocator.Stub使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IServiceLocator的用法示例。


在下文中一共展示了IServiceLocator.Stub方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FixtureSetup

        public virtual void FixtureSetup()
        {
            _unitOfWorkFactory = new EFUnitOfWorkFactory();
            _unitOfWorkFactory.RegisterContextProvider(() => new CodeOnlyContext("SandboxCodeOnly").Context);

            Locator = MockRepository.GenerateStub<IServiceLocator>();
            Locator.Stub(x => x.GetInstance<IUnitOfWorkFactory>()).Return(_unitOfWorkFactory);
            Locator.Stub(x => x.GetInstance<IState>()).Do(new Func<IState>(() => State));
            ServiceLocator.SetLocatorProvider(() => Locator);
        }
开发者ID:jordanyaker,项目名称:ncommon,代码行数:10,代码来源:EFRepositoryQueryTestsBase.cs

示例2: SetUp

 public void SetUp()
 {
     builder = new PizzaTypeEditorConvention();
     pizzaType = new PizzaType { Id = new Guid(), Name = "Test", Description = "Test description" };
     order = new PickupOrder { Id = new Guid(), PizzaType = pizzaType };
     services = MockRepository.GenerateStub<IServiceLocator>();
     repository = MockRepository.GenerateStub<IRepository>();
     stringifier = new Stringifier();
     repository.Stub(r => r.GetAll<PizzaType>()).Return(new List<PizzaType> { pizzaType });
     services.Stub(l => l.GetInstance<IRepository>()).Return(repository);
     services.Stub(l => l.GetInstance<Stringifier>()).Return(stringifier);
 }
开发者ID:randrews,项目名称:dovetail,代码行数:12,代码来源:PizzaTypeEditorConventionTester.cs

示例3: before

 public void before()
 {
     serviceLocator = MockRepository.GenerateStub<IServiceLocator>();
     shellView = MockRepository.GenerateMock<IShellView>();
     menuController = MockRepository.GenerateMock<IMenuController>();
     serviceLocator.Stub(x => x.GetInstance<IMenuController>()).Return(menuController);
 }
开发者ID:jenrom,项目名称:LogSpy,代码行数:7,代码来源:When_initializing_the_application_controller.cs

示例4: Setup

        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
            };
        }
开发者ID:RendaniTshinakaho,项目名称:PseudoCQRS,代码行数:27,代码来源:BaseReadExecuteControllerTests.cs

示例5: given_the_context_of

 protected override void given_the_context_of()
 {
     methodFactory = Mock<IMethodFactory>();
     info = typeof(MethodHost).GetMethod("Rescue");
     attribute = new RescueAttribute("Rescue");
     container = Stub<IServiceLocator>();
     container.Stub(x => x.GetInstance<IMethodFactory>()).Return(methodFactory).Repeat.Any();
 }
开发者ID:ssethi,项目名称:TestFrameworks,代码行数:8,代码来源:Rescue_filter.cs

示例6: given_the_context_of

 protected override void given_the_context_of()
 {
     methodFactory = Mock<IMethodFactory>();
     info = typeof(MethodHost).GetMethod("Callback");
     attribute = new AsyncActionAttribute {
         Callback = "Callback"
     };
     container = Stub<IServiceLocator>();
     container.Stub(x => x.GetInstance<IMethodFactory>()).Return(methodFactory).Repeat.Any();
 }
开发者ID:ssethi,项目名称:TestFrameworks,代码行数:10,代码来源:The_callback_filter.cs

示例7: Setup

        public void Setup()
        {
            _dbSessionManager = MockRepository.GenerateMock<IDbSessionManager>();
            _serviceLocator = MockRepository.GenerateMock<IServiceLocator>();
            _serviceLocator
                .Stub( x => x.GetInstance<IDbSessionManager>() )
                .Return( _dbSessionManager );

            ServiceLocator.SetLocatorProvider( () => _serviceLocator );
        }
开发者ID:RendaniTshinakaho,项目名称:PseudoCQRS,代码行数:10,代码来源:DbAttributesTests.cs

示例8: SetUp

        public void SetUp()
        {
            _flash = MockRepository.GenerateStub<IFlash>();
            _auth = MockRepository.GenerateStub<IAuthenticationContext>();
            _locator = MockRepository.GenerateStub<IServiceLocator>();
            ServiceLocator.SetLocatorProvider(()=> _locator);
            _resolver = MockRepository.GenerateStub<IUrlResolver>();
            _locator.Stub(l => l.GetInstance<IUrlResolver>()).Return(_resolver);
            _controller = new LoginController(_flash, _auth, _resolver);

            beforeEach();
        }
开发者ID:Anupam-,项目名称:fubumvc-contrib,代码行数:12,代码来源:LoginControllerTester.cs

示例9: given_the_context_of

        protected override void given_the_context_of()
        {
            methodFactory = Mock<IMethodFactory>();
            info = typeof(MethodHost).GetMethod("Preview");
            attribute = new PreviewAttribute("Preview");
            container = Stub<IServiceLocator>();
            container.Stub(x => x.GetInstance<IMethodFactory>()).Return(methodFactory).Repeat.Any();

            routedMessageHandler = Mock<IRoutedMessageHandler>();
            var metadata = new List<object>();
            routedMessageHandler.Stub(x => x.Metadata).Return(metadata).Repeat.Any();
        }
开发者ID:ssethi,项目名称:TestFrameworks,代码行数:12,代码来源:The_preview_filter.cs

示例10: SetUp

        public void SetUp()
        {
            _page = MockRepository.GenerateMock<IFubuPage<InputModel>>();
            _renderer = MockRepository.GenerateStub<IPartialRenderer>();
            _serviceLocator = MockRepository.GenerateStub<IServiceLocator>();
            
            _viewTypeRegistry = MockRepository.GenerateStub<IPartialViewTypeRegistry>();
            _serviceLocator.Stub(s => s.GetInstance<IPartialViewTypeRegistry>()).Return(_viewTypeRegistry);

            
            _model = new InputModel{Partials=new List<PartialModel>{new PartialModel()}};
            _page.Expect(p => p.Get<IElementGenerator<InputModel>>()).Return(MockRepository.GenerateMock<IElementGenerator<InputModel>>());;
            _page.Expect(p => p.Model).Return(_model);
            _page.Expect(p => p.Get<IPartialRenderer>()).Return(_renderer);
            _page.Expect(p => p.ServiceLocator).Return(_serviceLocator);
        }
开发者ID:DarthFubuMVC,项目名称:FubuMVC.WebForms,代码行数:16,代码来源:when_calling_partial_for_each.cs

示例11: Setup

        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 };
        }
开发者ID:RendaniTshinakaho,项目名称:PseudoCQRS,代码行数:18,代码来源:BaseCommandControllerTests.cs

示例12: SetUp

        public void SetUp()
        {
            _theRuleCache = new PageActivationRuleCache(new IPageActivationSource[0]);
            theServices = MockRepository.GenerateMock<IServiceLocator>();

            theRequest = new InMemoryFubuRequest();
            theServices.Stub(x => x.GetInstance<IFubuRequest>()).Return(theRequest);

            theActivator = new PageActivator(theServices, _theRuleCache);
        }
开发者ID:cprieto,项目名称:fubumvc,代码行数:10,代码来源:PageActivatorTester.cs

示例13: Using

 ///<summary>
 /// Configures NCommon using the specified mocked <see cref="IServiceLocator"/> instance.
 ///</summary>
 ///<param name="mockLocator">The <see cref="IServiceLocator"/> instance.</param>
 public static void Using(IServiceLocator mockLocator)
 {
     mockLocator.Stub(x => x.GetInstance<IState>()).Return(new FakeState());
     UnitOfWorkManager.SetTransactionManagerProvider(() => MockRepository.GenerateStub<ITransactionManager>());
 }
开发者ID:jordanyaker,项目名称:ncommon,代码行数:9,代码来源:Configure.cs


注:本文中的IServiceLocator.Stub方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。