public NancyInternalConfigurationFixture() { IAssemblyCatalog assemblyCatalog; #if !DNX assemblyCatalog = new AppDomainAssemblyCatalog(); #else assemblyCatalog = new LibraryManagerAssemblyCatalog(); #endif this.typeCatalog = new DefaultTypeCatalog(assemblyCatalog); }
public RazorViewEngineFixture() { IAssemblyCatalog assemblyCatalog; #if !DNX assemblyCatalog = new AppDomainAssemblyCatalog(); #else assemblyCatalog = new LibraryManagerAssemblyCatalog(); #endif var environment = new DefaultNancyEnvironment(); environment.Tracing( enabled: true, displayErrorTraces: true); this.configuration = A.Fake<IRazorConfiguration>(); this.engine = new RazorViewEngine(this.configuration, environment, assemblyCatalog); A.CallTo(() => this.configuration.GetAssemblyNames()).Returns(new[] { "Nancy.ViewEngines.Razor.Tests.Models" }); var cache = A.Fake<IViewCache>(); A.CallTo(() => cache.GetOrAdd(A<ViewLocationResult>.Ignored, A<Func<ViewLocationResult, Func<INancyRazorView>>>.Ignored)) .ReturnsLazily(x => { var result = x.GetArgument<ViewLocationResult>(0); return x.GetArgument<Func<ViewLocationResult, Func<INancyRazorView>>>(1).Invoke(result); }); this.renderContext = A.Fake<IRenderContext>(); A.CallTo(() => this.renderContext.ViewCache).Returns(cache); A.CallTo(() => this.renderContext.LocateView(A<string>.Ignored, A<object>.Ignored)) .ReturnsLazily(x => { var viewName = x.GetArgument<string>(0); return FindView(viewName); }); this.rootPathProvider = A.Fake<IRootPathProvider>(); A.CallTo(() => this.rootPathProvider.GetRootPath()).Returns(Path.Combine(Environment.CurrentDirectory, "TestViews")); this.fileSystemViewLocationProvider = new FileSystemViewLocationProvider(this.rootPathProvider, new DefaultFileSystemReader()); }
public RazorViewEngineFixture() { IAssemblyCatalog assemblyCatalog; #if !DNX assemblyCatalog = new AppDomainAssemblyCatalog(); #else assemblyCatalog = new LibraryManagerAssemblyCatalog(); #endif var environment = new DefaultNancyEnvironment(); environment.Tracing( enabled: true, displayErrorTraces: true); this.configuration = A.Fake <IRazorConfiguration>(); this.engine = new RazorViewEngine(this.configuration, environment, assemblyCatalog); A.CallTo(() => this.configuration.GetAssemblyNames()).Returns(new[] { "Nancy.ViewEngines.Razor.Tests.Models" }); var cache = A.Fake <IViewCache>(); A.CallTo(() => cache.GetOrAdd(A <ViewLocationResult> .Ignored, A <Func <ViewLocationResult, Func <INancyRazorView> > > .Ignored)) .ReturnsLazily(x => { var result = x.GetArgument <ViewLocationResult>(0); return(x.GetArgument <Func <ViewLocationResult, Func <INancyRazorView> > >(1).Invoke(result)); }); this.renderContext = A.Fake <IRenderContext>(); A.CallTo(() => this.renderContext.ViewCache).Returns(cache); A.CallTo(() => this.renderContext.LocateView(A <string> .Ignored, A <object> .Ignored)) .ReturnsLazily(x => { var viewName = x.GetArgument <string>(0); return(FindView(viewName)); }); this.rootPathProvider = A.Fake <IRootPathProvider>(); A.CallTo(() => this.rootPathProvider.GetRootPath()).Returns(Path.Combine(Environment.CurrentDirectory, "TestViews")); this.fileSystemViewLocationProvider = new FileSystemViewLocationProvider(this.rootPathProvider, new DefaultFileSystemReader()); }