public void Can_Register_NewApi_Routes_From_Assembly()
        {
            var routes = new ServiceRoutes();
            routes.AddFromAssembly(typeof(NewApiRestServiceWithAllVerbsImplemented).Assembly);

            RestPath restWithAllMethodsRoute =
                (from r in routes.RestPaths
                 where r.Path == "/NewApiRequestDto"
                 select r).FirstOrDefault();

            Assert.That(restWithAllMethodsRoute, Is.Not.Null);

            Assert.That(restWithAllMethodsRoute.AllowedVerbs.Contains("GET"));
            Assert.That(restWithAllMethodsRoute.AllowedVerbs.Contains("POST"));
            Assert.That(restWithAllMethodsRoute.AllowedVerbs.Contains("PUT"));
            Assert.That(restWithAllMethodsRoute.AllowedVerbs.Contains("DELETE"));
            Assert.That(restWithAllMethodsRoute.AllowedVerbs.Contains("PATCH"));

            RestPath restWithAllMethodsRoute2 =
                (from r in routes.RestPaths
                 where r.Path == "/NewApiRequestDto2"
                 select r).FirstOrDefault();

            Assert.That(restWithAllMethodsRoute2, Is.Not.Null);

            Assert.That(restWithAllMethodsRoute2.AllowedVerbs.Contains("GET"));
            Assert.That(restWithAllMethodsRoute2.AllowedVerbs.Contains("POST"));
            Assert.That(restWithAllMethodsRoute2.AllowedVerbs.Contains("PUT"));
            Assert.That(restWithAllMethodsRoute2.AllowedVerbs.Contains("DELETE"));
            Assert.That(restWithAllMethodsRoute2.AllowedVerbs.Contains("PATCH"));
        }
Beispiel #2
0
        public void Can_Register_NewApi_Routes_From_Assembly()
        {
            var routes = new ServiceRoutes();

            routes.AddFromAssembly(typeof(NewApiRestServiceWithAllVerbsImplemented).Assembly);

            RestPath restWithAllMethodsRoute =
                (from r in routes.RestPaths
                 where r.Path == "/NewApiRequestDto"
                 select r).FirstOrDefault();

            Assert.That(restWithAllMethodsRoute, Is.Not.Null);

            Assert.That(restWithAllMethodsRoute.AllowedVerbs.Contains("GET"));
            Assert.That(restWithAllMethodsRoute.AllowedVerbs.Contains("POST"));
            Assert.That(restWithAllMethodsRoute.AllowedVerbs.Contains("PUT"));
            Assert.That(restWithAllMethodsRoute.AllowedVerbs.Contains("DELETE"));
            Assert.That(restWithAllMethodsRoute.AllowedVerbs.Contains("PATCH"));

            RestPath restWithAllMethodsRoute2 =
                (from r in routes.RestPaths
                 where r.Path == "/NewApiRequestDto2"
                 select r).FirstOrDefault();

            Assert.That(restWithAllMethodsRoute2, Is.Not.Null);

            Assert.That(restWithAllMethodsRoute2.AllowedVerbs.Contains("GET"));
            Assert.That(restWithAllMethodsRoute2.AllowedVerbs.Contains("POST"));
            Assert.That(restWithAllMethodsRoute2.AllowedVerbs.Contains("PUT"));
            Assert.That(restWithAllMethodsRoute2.AllowedVerbs.Contains("DELETE"));
            Assert.That(restWithAllMethodsRoute2.AllowedVerbs.Contains("PATCH"));
        }
        public void InferRoutes()
        {
            loadAppHost = new BasicAppHost().Init();

            RouteNamingConvention.PropertyNamesToMatch.Add("Key");
            RouteNamingConvention.AttributeNamesToMatch.Add(typeof(KeyAttribute).Name);
            routes.AddFromAssembly(typeof(RouteInferenceTests).Assembly);
        }
        public void Can_Register_Routes_With_Partially_Implemented_REST_Verbs()
        {
            var routes = new ServiceRoutes();
            routes.AddFromAssembly(typeof(RestServiceWithSomeVerbsImplemented).Assembly);

            RestPath restWithAFewMethodsRoute = (from r in routes.RestPaths
                                                 where r.Path == "RestServiceWithSomeVerbsImplemented"
                                                 select r).FirstOrDefault();

            Assert.That(restWithAFewMethodsRoute, Is.Not.Null);

            Assert.That(restWithAFewMethodsRoute.AllowedVerbs.Contains("GET"), Is.True);
            Assert.That(restWithAFewMethodsRoute.AllowedVerbs.Contains("POST"), Is.False);
            Assert.That(restWithAFewMethodsRoute.AllowedVerbs.Contains("PUT"), Is.True);
            Assert.That(restWithAFewMethodsRoute.AllowedVerbs.Contains("DELETE"), Is.False);
            Assert.That(restWithAFewMethodsRoute.AllowedVerbs.Contains("PATCH"), Is.False);
        }
Beispiel #5
0
        public void Can_Register_Routes_With_Partially_Implemented_REST_Verbs()
        {
            var routes = new ServiceRoutes();

            routes.AddFromAssembly(typeof(RestServiceWithSomeVerbsImplemented).Assembly);

            RestPath restWithAFewMethodsRoute = (from r in routes.RestPaths
                                                 where r.Path == "RestServiceWithSomeVerbsImplemented"
                                                 select r).FirstOrDefault();

            Assert.That(restWithAFewMethodsRoute, Is.Not.Null);

            Assert.That(restWithAFewMethodsRoute.AllowedVerbs.Contains("GET"), Is.True);
            Assert.That(restWithAFewMethodsRoute.AllowedVerbs.Contains("POST"), Is.False);
            Assert.That(restWithAFewMethodsRoute.AllowedVerbs.Contains("PUT"), Is.True);
            Assert.That(restWithAFewMethodsRoute.AllowedVerbs.Contains("DELETE"), Is.False);
            Assert.That(restWithAFewMethodsRoute.AllowedVerbs.Contains("PATCH"), Is.False);
        }
		public void Can_Register_NewApi_Routes_With_Field_Id_and_Any_Fallback_From_Assembly()
		{
			var routes = new ServiceRoutes();
			routes.AddFromAssembly(typeof(NewApiRequestDtoWithFieldIdService).Assembly);

			var route = (from r in routes.RestPaths
						 where r.Path == "/NewApiRequestDtoWithFieldId"
						 select r).FirstOrDefault();

			Assert.That(route, Is.Not.Null);
			Assert.That(route.AllowedVerbs, Is.Null);

			route = (from r in routes.RestPaths
					 where r.Path == "/NewApiRequestDtoWithFieldId/{Id}"
					 select r).FirstOrDefault();

			Assert.That(route, Is.Not.Null);
			Assert.That(route.AllowedVerbs, Is.Null);
		}
Beispiel #7
0
		public void Can_Register_NewApi_Routes_With_Field_Id_and_Any_Fallback_From_Assembly()
		{
            var routes = new ServiceRoutes(appHost);
			routes.AddFromAssembly(typeof(NewApiRequestDtoWithFieldIdService).Assembly);

            var route = (from r in appHost.RestPaths
						 where r.Path == "/NewApiRequestDtoWithFieldId"
						 select r).FirstOrDefault();

			Assert.That(route, Is.Not.Null);
			Assert.That(route.AllowedVerbs, Is.Null);

            route = (from r in appHost.RestPaths
					 where r.Path == "/NewApiRequestDtoWithFieldId/{Id}"
					 select r).FirstOrDefault();

			Assert.That(route, Is.Not.Null);
			Assert.That(route.AllowedVerbs, Is.Null);
		}