public DefaultRouteResolverFixture()
        {
            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)).ReturnsLazily(x =>
                new FakeRoutePatternMatchResult(c =>
                {
                    c.IsMatch(((string)x.Arguments[0]).Equals(((string)x.Arguments[1])));
                    c.AddParameter("foo", "bar");
                }));

            this.resolver = new DefaultRouteResolver(this.catalog, this.matcher, this.moduleBuilder);
        }
Пример #2
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]);
        }
Пример #3
0
        public DefaultRouteResolverFixture()
        {
            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)).ReturnsLazily(x =>
                                                                                                       new FakeRoutePatternMatchResult(c =>
            {
                c.IsMatch(((string)x.Arguments[0]).Equals(((string)x.Arguments[1])));
                c.AddParameter("foo", "bar");
            }));

            this.resolver = new DefaultRouteResolver(this.catalog, this.matcher, this.moduleBuilder);
        }
Пример #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UriTemplateRouteResolver"/> class.
 /// </summary>
 /// <param name="inner">The inner.</param>
 /// <param name="moduleCatalog">The module catalog.</param>
 /// <param name="builder">The builder.</param>
 /// <param name="environment">The environment.</param>
 public UriTemplateRouteResolver(DefaultRouteResolver inner, INancyModuleCatalog moduleCatalog, INancyModuleBuilder builder, INancyEnvironment environment)
 {
     this.inner                     = inner;
     this.moduleCatalog             = moduleCatalog;
     this.builder                   = builder;
     this.globalizationConfiguraton = environment.GetValue <GlobalizationConfiguration>();
 }
Пример #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DefaultRouteResolver"/> class.
 /// </summary>
 /// <param name="nancyModuleCatalog">The module catalog that modules should be</param>
 /// <param name="routePatternMatcher">The route pattern matcher that should be used to verify if the route is a match to any of the registered routes.</param>
 /// <param name="moduleBuilder">The module builder that will make sure that the resolved module is full configured.</param>
 /// <param name="cache">The route cache that should be used to resolve modules from.</param>
 public DefaultRouteResolver(INancyModuleCatalog nancyModuleCatalog, IRoutePatternMatcher routePatternMatcher, INancyModuleBuilder moduleBuilder, IRouteCache cache)
 {
     this.nancyModuleCatalog = nancyModuleCatalog;
     this.routePatternMatcher = routePatternMatcher;
     this.moduleBuilder = moduleBuilder;
     this.cache = cache;
 }
Пример #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DefaultRouteResolver"/> class.
 /// </summary>
 /// <param name="nancyModuleCatalog">The module catalog that modules should be</param>
 /// <param name="routePatternMatcher">The route pattern matcher that should be used to verify if the route is a match to any of the registered routes.</param>
 /// <param name="moduleBuilder">The module builder that will make sure that the resolved module is full configured.</param>
 /// <param name="cache">The route cache that should be used to resolve modules from.</param>
 public DefaultRouteResolver(INancyModuleCatalog nancyModuleCatalog, IRoutePatternMatcher routePatternMatcher, INancyModuleBuilder moduleBuilder, IRouteCache cache)
 {
     this.nancyModuleCatalog  = nancyModuleCatalog;
     this.routePatternMatcher = routePatternMatcher;
     this.moduleBuilder       = moduleBuilder;
     this.cache = cache;
 }
        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]);
        }
Пример #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DefaultRouteResolver"/> class.
 /// </summary>
 /// <param name="nancyModuleCatalog">The module catalog that modules should be</param>
 /// <param name="routePatternMatcher">The route pattern matcher that should be used to verify if the route is a match to any of the registered routes.</param>
 /// <param name="moduleBuilder">The module builder that will make sure that the resolved module is full configured.</param>
 /// <param name="cache">The route cache that should be used to resolve modules from.</param>
 /// <param name="responseProcessors"></param>
 public DefaultRouteResolver(INancyModuleCatalog nancyModuleCatalog, IRoutePatternMatcher routePatternMatcher, INancyModuleBuilder moduleBuilder, IRouteCache cache, IEnumerable<IResponseProcessor> responseProcessors)
 {
     this.nancyModuleCatalog = nancyModuleCatalog;
     this.routePatternMatcher = routePatternMatcher;
     this.moduleBuilder = moduleBuilder;
     this.cache = cache;
     this.responseProcessors = responseProcessors;
 }
Пример #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DefaultRouteResolver"/> class.
 /// </summary>
 /// <param name="nancyModuleCatalog">The module catalog that modules should be</param>
 /// <param name="routePatternMatcher">The route pattern matcher that should be used to verify if the route is a match to any of the registered routes.</param>
 /// <param name="moduleBuilder">The module builder that will make sure that the resolved module is full configured.</param>
 /// <param name="cache">The route cache that should be used to resolve modules from.</param>
 /// <param name="responseProcessors"></param>
 public DefaultRouteResolver(INancyModuleCatalog nancyModuleCatalog, IRoutePatternMatcher routePatternMatcher, INancyModuleBuilder moduleBuilder, IRouteCache cache, IEnumerable <IResponseProcessor> responseProcessors)
 {
     this.nancyModuleCatalog  = nancyModuleCatalog;
     this.routePatternMatcher = routePatternMatcher;
     this.moduleBuilder       = moduleBuilder;
     this.cache = cache;
     this.responseProcessors = responseProcessors;
 }
Пример #10
0
        public DefaultRouteResolver(INancyModuleCatalog catalog, INancyModuleBuilder moduleBuilder, IRouteCache routeCache, IRouteResolverTrie trie)
        {
            this.catalog = catalog;
            this.moduleBuilder = moduleBuilder;
            this.routeCache = routeCache;
            this.trie = trie;

            this.BuildTrie();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="DefaultRouteResolver"/> class, using
        /// the provided <paramref name="catalog"/>, <paramref name="moduleBuilder"/>,
        /// <paramref name="routeCache"/> and <paramref name="trie"/>.
        /// </summary>
        /// <param name="catalog">A <see cref="INancyModuleCatalog"/> instance.</param>
        /// <param name="moduleBuilder">A <see cref="INancyModuleBuilder"/> instance.</param>
        /// <param name="routeCache">A <see cref="IRouteCache"/> instance.</param>
        /// <param name="trie">A <see cref="IRouteResolverTrie"/> instance.</param>
        public DefaultRouteResolver(INancyModuleCatalog catalog, INancyModuleBuilder moduleBuilder, IRouteCache routeCache, IRouteResolverTrie trie)
        {
            this.catalog       = catalog;
            this.moduleBuilder = moduleBuilder;
            this.routeCache    = routeCache;
            this.trie          = trie;

            this.BuildTrie();
        }
Пример #12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DefaultRouteResolver"/> class, using
        /// the provided <paramref name="catalog"/>, <paramref name="moduleBuilder"/>,
        /// <paramref name="routeCache"/> and <paramref name="trie"/>.
        /// </summary>
        /// <param name="catalog">A <see cref="INancyModuleCatalog"/> instance.</param>
        /// <param name="moduleBuilder">A <see cref="INancyModuleBuilder"/> instance.</param>
        /// <param name="routeCache">A <see cref="IRouteCache"/> instance.</param>
        /// <param name="trie">A <see cref="IRouteResolverTrie"/> instance.</param>
        public SoapRouteResolver(INancyModuleCatalog catalog, INancyModuleBuilder moduleBuilder, IRouteCache routeCache, IRouteResolverTrie trie)// : base(catalog, moduleBuilder, routeCache, trie)
        {
            this.catalog       = catalog;
            this.moduleBuilder = moduleBuilder;
            this.routeCache    = routeCache;
            this.trie          = trie;

            this.BuildTrie();
        }
Пример #13
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DefaultRouteResolver"/> class, using
        /// the provided <paramref name="catalog"/>, <paramref name="moduleBuilder"/>,
        /// <paramref name="routeCache"/> and <paramref name="trie"/>.
        /// </summary>
        /// <param name="catalog">An <see cref="INancyModuleCatalog"/> instance.</param>
        /// <param name="moduleBuilder">An <see cref="INancyModuleBuilder"/> instance.</param>
        /// <param name="routeCache">An <see cref="IRouteCache"/> instance.</param>
        /// <param name="trie">An <see cref="IRouteResolverTrie"/> instance.</param>
        /// <param name="environment">An <see cref="INancyEnvironment"/> instance.</param>
        public DefaultRouteResolver(INancyModuleCatalog catalog, INancyModuleBuilder moduleBuilder, IRouteCache routeCache, IRouteResolverTrie trie, INancyEnvironment environment)
        {
            this.catalog = catalog;
            this.moduleBuilder = moduleBuilder;
            this.routeCache = routeCache;
            this.trie = trie;
            this.configuration = new Lazy<RouteConfiguration>(environment.GetValue<RouteConfiguration>);

            this.BuildTrie();
        }
Пример #14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DefaultRouteResolver"/> class.
 /// </summary>
 /// <param name="nancyModuleCatalog">The module catalog that modules should be</param>
 /// <param name="routePatternMatcher">The route pattern matcher that should be used to verify if the route is a match to any of the registered routes.</param>
 /// <param name="moduleBuilder">The module builder that will make sure that the resolved module is full configured.</param>
 /// <param name="cache">The route cache that should be used to resolve modules from.</param>
 /// <param name="responseProcessors"></param>
 public NSembleRouteResolver(INancyModuleCatalog nancyModuleCatalog, IRoutePatternMatcher routePatternMatcher, INancyModuleBuilder moduleBuilder, IRouteCache cache,
                             IEnumerable <IResponseProcessor> responseProcessors, global::Nancy.TinyIoc.TinyIoCContainer container)
 {
     this.nancyModuleCatalog  = nancyModuleCatalog;
     this.routePatternMatcher = routePatternMatcher;
     this.moduleBuilder       = moduleBuilder;
     this.cache = cache;
     this.responseProcessors = responseProcessors;
     _container = container;
 }
Пример #15
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DefaultRouteResolver"/> class, using
        /// the provided <paramref name="catalog"/>, <paramref name="moduleBuilder"/>,
        /// <paramref name="routeCache"/> and <paramref name="trie"/>.
        /// </summary>
        /// <param name="catalog">An <see cref="INancyModuleCatalog"/> instance.</param>
        /// <param name="moduleBuilder">An <see cref="INancyModuleBuilder"/> instance.</param>
        /// <param name="routeCache">An <see cref="IRouteCache"/> instance.</param>
        /// <param name="trie">An <see cref="IRouteResolverTrie"/> instance.</param>
        /// <param name="environment">An <see cref="INancyEnvironment"/> instance.</param>
        public DefaultRouteResolver(INancyModuleCatalog catalog, INancyModuleBuilder moduleBuilder, IRouteCache routeCache, IRouteResolverTrie trie, INancyEnvironment environment)
        {
            this.catalog       = catalog;
            this.moduleBuilder = moduleBuilder;
            this.routeCache    = routeCache;
            this.trie          = trie;
            this.configuration = new Lazy <RouteConfiguration>(environment.GetValue <RouteConfiguration>);

            this.BuildTrie();
        }
Пример #16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DefaultRouteResolver"/> class.
 /// </summary>
 /// <param name="nancyModuleCatalog">The module catalog that modules should be</param>
 /// <param name="routePatternMatcher">The route pattern matcher that should be used to verify if the route is a match to any of the registered routes.</param>
 /// <param name="moduleBuilder">The module builder that will make sure that the resolved module is full configured.</param>
 /// <param name="cache">The route cache that should be used to resolve modules from.</param>
 /// <param name="responseProcessors"></param>
 public NSembleRouteResolver(INancyModuleCatalog nancyModuleCatalog, IRoutePatternMatcher routePatternMatcher, INancyModuleBuilder moduleBuilder, IRouteCache cache,
     IEnumerable<IResponseProcessor> responseProcessors, global::Nancy.TinyIoc.TinyIoCContainer container)
 {
     this.nancyModuleCatalog = nancyModuleCatalog;
     this.routePatternMatcher = routePatternMatcher;
     this.moduleBuilder = moduleBuilder;
     this.cache = cache;
     this.responseProcessors = responseProcessors;
     _container = container;
 }
Пример #17
0
 /// <summary>
 /// Configures the bootstrapper to use the provided instance of <see cref="INancyModuleBuilder"/>.
 /// </summary>
 /// <param name="nancyModuleBuilder">The <see cref="INancyModuleBuilder"/> instance that should be used by the bootstrapper.</param>
 /// <returns>An instance to the current <see cref="FakeNancyBootstrapperConfigurator"/>.</returns>
 public FakeNancyBootstrapperConfigurator ModuleBuilder(INancyModuleBuilder nancyModuleBuilder)
 {
     this.bootstrapper.configuredInstances[typeof(INancyModuleBuilder)] = nancyModuleBuilder;
     return(this);
 }