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); /// Vendors example : Get a list of all vendors /// Response.Write("<h1>Vendors</h1><p>"); if (ObjHd4.DeviceVendors()) { Response.Write(ObjHd4.GetRawReply()); } else { Response.Write(ObjHd4.GetError()); } Response.Write("</p>"); }
public void test19_ultimate_deviceVendors() { HttpRequest request = new HttpRequest(null, "http://localhost", null); _objHd4 = new Hd4(request, _ultimateConfig); bool result = _objHd4.DeviceVendors(); Dictionary<string, dynamic> reply = _objHd4.GetReply(); Assert.IsTrue(result); Assert.AreEqual(0, reply["status"]); Assert.AreEqual("OK", reply["message"]); Assert.Contains("Nokia", reply["vendor"]); Assert.Contains("Samsung", reply["vendor"]); }