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); // Models example : Get a list of all models for a specific vendor Response.Write("<h1>Nokia Models</h1><p>"); if (ObjHd4.DeviceModels("Nokia")) { Response.Write(ObjHd4.GetRawReply()); } else { Response.Write(ObjHd4.GetError()); } Response.Write("</p>"); }
public void test20_ultimate_deviceModels() { HttpRequest request = new HttpRequest(null, "http://localhost", null); _objHd4 = new Hd4(request, _ultimateConfig); bool result = _objHd4.DeviceModels("Nokia"); Dictionary<string, dynamic> reply = _objHd4.GetReply(); Assert.IsTrue(result); Assert.AreEqual(0, reply["status"]); Assert.AreEqual("OK", reply["message"]); Assert.IsNotEmpty(reply["message"]); Assert.Greater(reply["model"].Count, 700); }