public DefaultRouteResolverFixture() { this.routeDescriptionProvider = A.Fake<IRouteDescriptionProvider>(); this.moduleBuilder = A.Fake<INancyModuleBuilder>(); A.CallTo(() => this.moduleBuilder.BuildModule(A<NancyModule>.Ignored, A<NancyContext>.Ignored)). ReturnsLazily(r => r.Arguments[0] as NancyModule); this.catalog = A.Fake<INancyModuleCatalog>(); A.CallTo(() => this.catalog.GetModuleByKey(A<string>.Ignored, A<NancyContext>.Ignored)).Returns(expectedModule); this.expectedAction = x => HttpStatusCode.OK; this.expectedModule = new FakeNancyModule(x => x.AddGetRoute("/foo/bar", this.expectedAction)); A.CallTo(() => this.catalog.GetModuleByKey(A<string>.Ignored, A<NancyContext>.Ignored)).ReturnsLazily(() => this.expectedModule); this.matcher = A.Fake<IRoutePatternMatcher>(); A.CallTo(() => this.matcher.Match(A<string>.Ignored, A<string>.Ignored, A<IEnumerable<string>>.Ignored, A<NancyContext>.Ignored)).ReturnsLazily(x => new FakeRoutePatternMatchResult(c => { c.IsMatch(((string)x.Arguments[0]).Equals(((string)x.Arguments[1]))); c.AddParameter("foo", "bar"); })); this.moduleKeyGenerator = A.Fake<IModuleKeyGenerator>(); A.CallTo(() => moduleKeyGenerator.GetKeyForModuleType(A<Type>._)).ReturnsLazily(x => (string)x.Arguments[0]); }
public DefaultRouteResolverFixture() { this.routeDescriptionProvider = A.Fake <IRouteDescriptionProvider>(); this.moduleBuilder = A.Fake <INancyModuleBuilder>(); A.CallTo(() => this.moduleBuilder.BuildModule(A <NancyModule> .Ignored, A <NancyContext> .Ignored)). ReturnsLazily(r => r.Arguments[0] as NancyModule); this.catalog = A.Fake <INancyModuleCatalog>(); A.CallTo(() => this.catalog.GetModuleByKey(A <string> .Ignored, A <NancyContext> .Ignored)).Returns(expectedModule); this.expectedAction = x => HttpStatusCode.OK; this.expectedModule = new FakeNancyModule(x => x.AddGetRoute("/foo/bar", this.expectedAction)); A.CallTo(() => this.catalog.GetModuleByKey(A <string> .Ignored, A <NancyContext> .Ignored)).ReturnsLazily(() => this.expectedModule); this.matcher = A.Fake <IRoutePatternMatcher>(); A.CallTo(() => this.matcher.Match(A <string> .Ignored, A <string> .Ignored, A <IEnumerable <string> > .Ignored, A <NancyContext> .Ignored)).ReturnsLazily(x => new FakeRoutePatternMatchResult(c => { c.IsMatch(((string)x.Arguments[0]).Equals(((string)x.Arguments[1]))); c.AddParameter("foo", "bar"); })); this.moduleKeyGenerator = A.Fake <IModuleKeyGenerator>(); A.CallTo(() => moduleKeyGenerator.GetKeyForModuleType(A <Type> ._)).ReturnsLazily(x => (string)x.Arguments[0]); }
/// <summary> /// Initializes a new instance of the RouteCacheFixture class. /// </summary> public RouteCacheFixture() { this.routeDescriptionProvider = A.Fake<IRouteDescriptionProvider>(); this.routeSegmentExtractor = A.Fake<IRouteSegmentExtractor>(); this.fakeModuleCatalog = new FakeModuleCatalog(); this.routeCache = new RouteCache(this.fakeModuleCatalog, A.Fake<INancyContextFactory>(), this.routeSegmentExtractor, this.routeDescriptionProvider, A.Fake<ICultureService>()); }
/// <summary> /// Initializes a new instance of the RouteCacheFixture class. /// </summary> public RouteCacheFixture() { this.routeDescriptionProvider = A.Fake <IRouteDescriptionProvider>(); this.routeSegmentExtractor = A.Fake <IRouteSegmentExtractor>(); this.fakeModuleCatalog = new FakeModuleCatalog(); this.routeCache = new RouteCache(this.fakeModuleCatalog, new FakeModuleKeyGenerator(), A.Fake <INancyContextFactory>(), this.routeSegmentExtractor, this.routeDescriptionProvider, A.Fake <ICultureService>()); }
/// <summary> /// Initializes a new instance of the RouteCacheFixture class. /// </summary> public RouteCacheFixture() { this.routeDescriptionProvider = A.Fake<IRouteDescriptionProvider>(); this.routeSegmentExtractor = A.Fake<IRouteSegmentExtractor>(); this.fakeModuleCatalog = new FakeModuleCatalog(); this.routeCache = new RouteCache(this.fakeModuleCatalog, new FakeModuleKeyGenerator(), A.Fake<INancyContextFactory>(), this.routeSegmentExtractor, this.routeDescriptionProvider); }
/// <summary> /// Initializes a new instance of the RouteCacheFixture class. /// </summary> public RouteCacheFixture() { this.routeDescriptionProvider = A.Fake <IRouteDescriptionProvider>(); this.routeSegmentExtractor = A.Fake <IRouteSegmentExtractor>(); this.routeMetadataProviders = new IRouteMetadataProvider[0]; this.fakeModuleCatalog = new FakeModuleCatalog(); this.routeCache = new RouteCache(this.fakeModuleCatalog, A.Fake <INancyContextFactory>(), this.routeSegmentExtractor, this.routeDescriptionProvider, A.Fake <ICultureService>(), this.routeMetadataProviders); }
/// <summary> /// Initializes a new instance of the <see cref="RouteCache"/> class. /// </summary> /// <param name="moduleCatalog">The <see cref="INancyModuleCatalog"/> that should be used by the cache.</param> /// <param name="moduleKeyGenerator">The <see cref="IModuleKeyGenerator"/> used to generate module keys.</param> /// <param name="contextFactory">The <see cref="INancyContextFactory"/> that should be used to create a context instance.</param> /// <param name="routeSegmentExtractor"> </param> public RouteCache(INancyModuleCatalog moduleCatalog, IModuleKeyGenerator moduleKeyGenerator, INancyContextFactory contextFactory, IRouteSegmentExtractor routeSegmentExtractor, IRouteDescriptionProvider routeDescriptionProvider) { this.moduleKeyGenerator = moduleKeyGenerator; this.routeSegmentExtractor = routeSegmentExtractor; this.routeDescriptionProvider = routeDescriptionProvider; using (var context = contextFactory.Create()) { this.BuildCache(moduleCatalog.GetAllModules(context)); } }
/// <summary> /// Initializes a new instance of the <see cref="RouteCache"/> class. /// </summary> /// <param name="moduleCatalog">The <see cref="INancyModuleCatalog"/> that should be used by the cache.</param> /// <param name="contextFactory">The <see cref="INancyContextFactory"/> that should be used to create a context instance.</param> /// <param name="routeSegmentExtractor"> </param> public RouteCache(INancyModuleCatalog moduleCatalog, INancyContextFactory contextFactory, IRouteSegmentExtractor routeSegmentExtractor, IRouteDescriptionProvider routeDescriptionProvider, ICultureService cultureService) { this.routeSegmentExtractor = routeSegmentExtractor; this.routeDescriptionProvider = routeDescriptionProvider; var request = new Request("GET", "/", "http"); using (var context = contextFactory.Create(request)) { this.BuildCache(moduleCatalog.GetAllModules(context)); } }