protected void Page_Load(object sender, EventArgs e) { // Ensure config file is setup if (!File.Exists(Server.MapPath(ConfigFile))) { throw new Exception("Config file not found"); } var serializer = new JavaScriptSerializer(); string jsonText = System.IO.File.ReadAllText(Server.MapPath(ConfigFile)); Config = serializer.Deserialize<Dictionary<string, dynamic>>(jsonText); if (Config["username"] == "your_api_username") { throw new Exception("Please configure your username, secret and site_id"); } ObjHd4 = new Hd4(Request, ConfigFile); // View information for a specific handset Response.Write("<h1>Nokia N95 Properties</h1><p>"); if (ObjHd4.DeviceView("Nokia", "N95")) { Response.Write(ObjHd4.GetRawReply()); } else { Response.Write(ObjHd4.GetError()); } Response.Write("</p>"); }
public void test21_ultimate_deviceView() { HttpRequest request = new HttpRequest(null, "http://localhost", null); _objHd4 = new Hd4(request, _ultimateConfig); bool result = _objHd4.DeviceView("Nokia", "N95"); Dictionary<string, dynamic> reply = _objHd4.GetReply(); Assert.IsTrue(result); Assert.AreEqual(0, reply["status"]); Assert.AreEqual("OK", reply["message"]); Assert.AreEqual(_jss.Serialize(_devices["NokiaN95"]), _jss.Serialize(reply["device"])); }