public void AddImplicitProperties_AddUninitializedModule_AddsModuleToRoutes() { var m = new FakeModuleWithUninitializedModuleProperty (); var request = new MockHttpRequest ("GET", "/MyModule/FakeAction"); var r = m.Routes.Find (request); Assert.IsNotNull (r); }
public void TestDeleteToTarget() { var m = new MockManosModule (); var req = new MockHttpRequest ("DELETE", "/Foobar"); m.Delete ("/Foobar", new ManosAction (FakeAction)); Assert.AreEqual (new ManosAction (FakeAction), m.Routes.Find (req).Action); req = new MockHttpRequest ("GET", "/Foobar"); Assert.IsNull (m.Routes.Find (req)); }
public void Find_PartialMatchAtBeginningOfChildlessHandler_ReturnsProperRoute() { var rh_bad = new RouteHandler ("foo", "GET", new ActionTarget (FakeAction)); var rh_good = new RouteHandler ("foobar", "GET", new ActionTarget (FakeAction2)); var rh = new RouteHandler (); rh.Children.Add (rh_bad); rh.Children.Add (rh_good); var request = new MockHttpRequest ("GET", "foobar"); var res = rh.Find (request); Assert.AreEqual (rh_good.Target, res); }
public void TestDeleteToModule() { var m = new MockManosModule (); var req = new MockHttpRequest ("DELETE", "/FakeModule/FakeAction"); m.Delete ("/FakeModule", new FakeModule ()); // // I guess technically this is testing the auto name registering too // Assert.AreEqual (new ManosAction (FakeModule.FakeAction), m.Routes.Find (req).Action); req = new MockHttpRequest ("GET", "/FakeModule/FakeAction"); Assert.IsNull (m.Routes.Find (req)); }
public void TestChangePatterns() { // // Ensure that changing the patterns property works. // This is a bit of an edge case because internally // the patterns strings are cached as an array of // regexes. // var target = new MockManosTarget (); var rh = new RouteHandler ("^foo", "GET", target); var request = new MockHttpRequest ("GET", "foo"); Assert.AreEqual (target, rh.Find (request), "sanity-1"); rh.Patterns [0] = "baz"; Assert.IsNull (rh.Find (request), "sanity-2"); request = new MockHttpRequest ("GET", "baz"); Assert.AreEqual (target, rh.Find (request), "changed"); }
public void UriParamsTestDeep() { var rh = new RouteHandler ("(?<animal>.+)/", "GET") { new RouteHandler ("(?<name>.+)", "GET", new ActionTarget (FakeAction)), }; var request = new MockHttpRequest ("GET", "dog/roxy"); Should.NotBeNull (rh.Find (request), "target"); Should.NotBeNull (request.UriData, "uri-data"); Assert.AreEqual ("dog", request.UriData ["animal"]); Assert.AreEqual ("roxy", request.UriData ["name"]); }
public void UriParamsTest() { var rh = new RouteHandler ("(?<name>.+)", "GET", new ActionTarget (FakeAction)); var request = new MockHttpRequest ("GET", "hello"); Should.NotBeNull (rh.Find (request), "target"); Should.NotBeNull (request.UriData, "uri-data"); Assert.AreEqual ("hello", request.UriData ["name"]); }
public void TestStrMatchDeep() { var target = new MockManosTarget (); var rh = new RouteHandler ("foo/", "GET") { new RouteHandler ("bar", "GET", target), }; var request = new MockHttpRequest ("GET", "foo/bar"); Assert.AreEqual (target, rh.Find (request)); request = new MockHttpRequest ("GET", "foo/foo"); Assert.IsNull (rh.Find (request), "repeate-input"); request = new MockHttpRequest ("GET", "foo/badbar"); Assert.IsNull (rh.Find (request), "matched-input"); }
public void TestStrMatch() { var target = new MockManosTarget (); var rh = new RouteHandler ("^foo", "GET", target); var request = new MockHttpRequest ("GET", "foo"); Assert.AreEqual (target, rh.Find (request), "should-match"); request = new MockHttpRequest ("GET", "garbage-foo"); Assert.IsNull (rh.Find (request), "garbage-input"); }
public void TestSetPatternsNull() { var target = new MockManosTarget (); var rh = new RouteHandler ("^foo", "GET", target); var request = new MockHttpRequest ("GET", "foo"); Assert.AreEqual (target, rh.Find (request), "sanity-1"); rh.Patterns = null; Assert.IsNull (rh.Find (request), "is null"); }
public void TestRouteToTarget() { string [] methods = new string [] { "GET", "PUT", "POST", "HEAD", "DELETE", "TRACE", "OPTIONS", }; for (int i = 0; i < methods.Length; i++) { var m = new MockManosModule (); var req = new MockHttpRequest (methods [i], "/Foobar"); m.Route ("/Foobar", new ManosAction (FakeAction)); Assert.AreEqual (new ManosAction (FakeAction), m.Routes.Find (req).Action); } }
public void TestRouteToModule() { string [] methods = new string [] { "GET", "PUT", "POST", "HEAD", "DELETE", "TRACE", "OPTIONS", }; for (int i = 0; i < methods.Length; i++) { var m = new MockManosModule (); var req = new MockHttpRequest (methods [i], "/FakeModule/FakeAction"); m.Route ("/FakeModule", new FakeModule ()); // // I guess technically this is testing the auto name registering too // Assert.AreEqual (new ManosAction (FakeModule.FakeAction), m.Routes.Find (req).Action); } }
public void TestPutToTarget() { var m = new MockManosModule (); var req = new MockHttpRequest ("PUT", "/Foobar"); m.Put ("/Foobar", new ManosAction (FakeAction)); Assert.AreEqual (new ManosAction (FakeAction), m.Routes.Find (req).Action); req = new MockHttpRequest ("POST", "/Foobar"); Assert.IsNull (m.Routes.Find (req)); }
public void TestOptionsToTarget() { var m = new MockManosModule (); var req = new MockHttpRequest ("OPTIONS", "/Foobar"); m.Options ("/Foobar", new ManosAction (FakeAction)); Assert.AreEqual (new ManosAction (FakeAction), m.Routes.Find (req).Action); req = new MockHttpRequest ("GET", "/Foobar"); Assert.IsNull (m.Routes.Find (req)); }