Exemplo n.º 1
0
        public void TestWebServiceGreedyStarFunctionality()
        {
            var browser = new Browser(SidModuleAssemblies);
            EndPointGroup group;

            var result = RestfulMethodDispatcher.WebMethodEndPoints.TryGetValue(HttpMethod.Get,
                out group);

            Assert.IsTrue(result);

            Regex pathRegex;
            var path = "FrankZappa/DukeEllington";
            var fullPath = "testcontent/testobject/path/" + path;

            var uri = new Uri("http://localhost:8081/" + fullPath);
            var endPoint = group.ResolveRequest(uri, out pathRegex);
            Assert.IsNotNull(endPoint);

            var request = new RestfulTestServerRequest {
                Url = uri,
                HttpMethod = HttpMethod.Get,
                Match = pathRegex.Match(fullPath),
            };
            Assert.AreEqual(1, endPoint.Parameters.Count);
            var parm = endPoint.Parameters[0];
            Assert.IsTrue(parm is PathAttribute);

            var moduleInstance = Activator.CreateInstance(endPoint.ModuleType) as SidModule;
            var paramValue = parm.GetParamValue(request, moduleInstance) as string;
            Assert.IsNotNull(paramValue);
            Assert.AreEqual(path, paramValue);
        }
Exemplo n.º 2
0
 public void TestBindAttributeNoPostBody()
 {
     var browser = new Browser(SidModuleAssemblies);
     var response = browser.Put("/testcontent/testobject/default");
     Assert.IsNotNull(response.Body);
     var testObj = JsonConvert.DeserializeObject<SidTestObject>(response.Body);
     Assert.AreEqual("sentinalValue", testObj.Id);
 }
Exemplo n.º 3
0
        public void TestMatchQueryInTerminalPathParam()
        {
            var browser = new Browser(SidModuleAssemblies);

            var response = browser.Get("/testcontent/testobject/15?x");
            Assert.IsNotNull(response);
            Assert.IsNotNull(response.Body);
            var testObj = JsonConvert.DeserializeObject<SidTestObject>(response.Body);

            Assert.AreEqual("15", testObj.Id);
        }