本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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
};
}
示例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();
}
示例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();
}
示例7: Setup
public void Setup()
{
_dbSessionManager = MockRepository.GenerateMock<IDbSessionManager>();
_serviceLocator = MockRepository.GenerateMock<IServiceLocator>();
_serviceLocator
.Stub( x => x.GetInstance<IDbSessionManager>() )
.Return( _dbSessionManager );
ServiceLocator.SetLocatorProvider( () => _serviceLocator );
}
示例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();
}
示例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();
}
示例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);
}
示例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 };
}
示例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);
}
示例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>());
}