Ejemplo n.º 1
0
        public void GetResourceListing_OneApis()
        {
            var uri = new Uri(ROOT + "/this/is?field=3&test=mytest");

            var apiDescs = new List <ApiDescription>()
            {
                TestHelper.GetApiDescription("yada")
            };
            //var apiDescs = new List<ApiDescription>(){
            //    new ApiDescription()
            //        {
            //            ActionDescriptor = new ReflectedHttpActionDescriptor(){ControllerDescriptor = new HttpControllerDescriptor(){ControllerName = "somecontrolerName"}},
            //            RelativePath = "relativePathHere",
            //            Documentation = "somedocs"
            //        },
            //};
            var factory = new ResourceListingFactory(VIRTUAL_DIR, apiDescs);

            var listing = factory.CreateResourceListing(uri);

            Assert.AreEqual(1, listing.apis.Count(), "api count");
            Assert.AreEqual("1.2.3.4", listing.apiVersion, "api version");
            Assert.AreEqual(ROOT + VIRTUAL_DIR + DOCS_ROUTE, listing.basePath, "basePath");
            Assert.AreEqual("2.0", listing.swaggerVersion, "swaggerVersion");

            Debug.WriteLine(JsonConvert.SerializeObject(listing));
        }
Ejemplo n.º 2
0
        public HttpResponseMessage Get()
        {
            // Arrange
            var uri = base.ControllerContext.Request.RequestUri;

            // Act
            var resourceListing = _resourceListingFactory.CreateResourceListing(uri);

            //Answer
            var resp = WrapResponse(resourceListing);

            return(resp);
        }
Ejemplo n.º 3
0
        public void GetResourceListing_NoApis()
        {
            var uri      = new Uri(ROOT + "/this/is?field=3&test=mytest");
            var apiDescs = new List <ApiDescription>();

            var factory = new ResourceListingFactory(VIRTUAL_DIR, apiDescs);

            var listing = factory.CreateResourceListing(uri);

            Assert.AreEqual(0, listing.apis.Count(), "api count");
            Assert.AreEqual("1.2.3.4", listing.apiVersion, "api version");
            Assert.AreEqual(ROOT + VIRTUAL_DIR + DOCS_ROUTE, listing.basePath, "basePath");
            Assert.AreEqual("2.0", listing.swaggerVersion, "swaggerVersion");

            Debug.WriteLine(JsonConvert.SerializeObject(listing));
        }