Exemplo n.º 1
0
        public void ScriptGenerator()
        {
            var url     = "http://localhost:37564";
            var host    = new MyHostFactory().CreateServiceHost(typeof(HogeService));
            var binding = new WebHttpBinding();

            host.AddServiceEndpoint(typeof(IHogeService), binding, url);
            host.Open();
            try
            {
                var wc = new WebClient();
                var s  = wc.DownloadString(url + "/js");
                Assert.IsTrue(s.IndexOf("IHogeService") > 0, "#1");
                Assert.IsTrue(s.IndexOf("Join") > 0, "#2");
                s = wc.DownloadString(url + "/jsdebug");
                Assert.IsTrue(s.IndexOf("IHogeService") > 0, "#3");
                Assert.IsTrue(s.IndexOf("Join") > 0, "#4");
                s = wc.DownloadString(url + "/Join?s1=foo&s2=bar");
                Assert.AreEqual("{\"d\":\"foobar\"}", s, "#5");
            }
            finally
            {
                host.Close();
            }
        }
Exemplo n.º 2
0
		public void ScriptGenerator ()
		{
			var url = "http://localhost:" + NetworkHelpers.FindFreePort ();
			var host = new MyHostFactory ().CreateServiceHost (typeof (HogeService));
			var binding = new WebHttpBinding ();
			host.AddServiceEndpoint (typeof (IHogeService), binding, url);
			host.Open ();
			try {
				var wc = new WebClient ();
				var s = wc.DownloadString (url + "/js");
				Assert.IsTrue (s.IndexOf ("IHogeService") > 0, "#1");
				Assert.IsTrue (s.IndexOf ("Join") > 0, "#2");
				s = wc.DownloadString (url + "/jsdebug");
				Assert.IsTrue (s.IndexOf ("IHogeService") > 0, "#3");
				Assert.IsTrue (s.IndexOf ("Join") > 0, "#4");
				s = wc.DownloadString (url + "/Join?s1=foo&s2=bar");
				Assert.AreEqual ("{\"d\":\"foobar\"}", s, "#5");
			} finally {
				host.Close ();
			}
		}