本文整理汇总了C#中IServiceLocator.Expect方法的典型用法代码示例。如果您正苦于以下问题:C# IServiceLocator.Expect方法的具体用法?C# IServiceLocator.Expect怎么用?C# IServiceLocator.Expect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IServiceLocator
的用法示例。
在下文中一共展示了IServiceLocator.Expect方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Setup
public void Setup()
{
if (File.Exists(_databasePath))
File.Delete(_databasePath);
//Configure Db4o to cascade updates on Order and Customer entities. (Since they are our Aggregate Roots)
var configuration = Db4oFactory.Configure();
configuration.ObjectClass(typeof (Order)).CascadeOnUpdate(true);
configuration.ObjectClass(typeof (Customer)).CascadeOnDelete(true);
_db4oServer = Db4oFactory.OpenServer(_databasePath, 0);
Db4oUnitOfWorkFactory.SetContainerProvider(() => _db4oServer.OpenClient());
_mockLocator = MockRepository.GenerateMock<IServiceLocator>();
_mockLocator.Expect(x => x.GetInstance<IUnitOfWorkFactory>())
.Return(new Db4oUnitOfWorkFactory())
.Repeat.Any();
ServiceLocator.SetLocatorProvider(() => _mockLocator);
}
示例2: ExtendedTester
public ExtendedTester()
{
var testRoot = Path.Combine(Directory.GetCurrentDirectory(), "Templates");
var pathApp = Path.Combine(testRoot, "App");
var pathPackage1 = Path.Combine(pathApp, "fubu-packages", "Package1", "WebContent");
var pathPackage2 = Path.Combine(testRoot, "Package2");
var allTemplates = new TemplateRegistry<IRazorTemplate>();
var razorSettings = new RazorEngineSettings();
var razorSet = razorSettings.Search;
new ContentFolder(TemplateConstants.HostOrigin, pathApp).FindFiles(razorSet)
.Union(new ContentFolder("Package1", pathPackage1).FindFiles(razorSet)
.Union(new ContentFolder("Package2", pathPackage2).FindFiles(razorSet)))
.Each(x =>
{
if (x.Provenance == TemplateConstants.HostOrigin && x.Path.StartsWith(pathPackage1)) return;
allTemplates.Register(new Template(x.Path, x.ProvenancePath, x.Provenance));
});
var viewPathPolicy = new ViewPathPolicy<IRazorTemplate>();
allTemplates.Each(x =>
{
viewPathPolicy.Apply(x);
x.Descriptor = new ViewDescriptor<IRazorTemplate>(x);
});
var commonNamespaces = new CommonViewNamespaces();
commonNamespaces.AddForType<string>();
_templateFactory = new TemplateFactoryCache(commonNamespaces, razorSettings, new TemplateCompiler(), new RazorTemplateGenerator());
_pak1TemplateRegistry = new TemplateRegistry<IRazorTemplate>(allTemplates.ByOrigin(Package1));
_pak2TemplateRegistry = new TemplateRegistry<IRazorTemplate>(allTemplates.ByOrigin(Package2));
_appTemplateRegistry = new TemplateRegistry<IRazorTemplate>(allTemplates.FromHost());
_serviceLocator = MockRepository.GenerateMock<IServiceLocator>();
var sharingGraph = new SharingGraph();
sharingGraph.Dependency("Package1", ContentFolder.Application);
sharingGraph.Dependency("Package2", ContentFolder.Application);
var templateDirectory = new TemplateDirectoryProvider<IRazorTemplate>(new SharedPathBuilder(), allTemplates,
sharingGraph);
_sharedTemplateLocator = new SharedTemplateLocator<IRazorTemplate>(templateDirectory, allTemplates,
new RazorTemplateSelector());
var partialRenderer = new PartialRenderer(_sharedTemplateLocator, _templateFactory);
_serviceLocator.Expect(x => x.GetInstance(Arg.Is(typeof (IPartialRenderer)))).Return(partialRenderer);
_serviceLocator.Expect(x => x.GetInstance(typeof (IOutputWriter))).Return(MockRepository.GenerateMock<IOutputWriter>());
}