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); // What handset have this attribute ? Response.Write("<h1>Nokia Models</h1><p>"); if (ObjHd4.DeviceWhatHas("network","CDMA")) { Response.Write(ObjHd4.GetRawReply()); } else { Response.Write(ObjHd4.GetError()); } Response.Write("</p>"); }
public void test22_ultimate_deviceDeviceWhatHas() { HttpRequest request = new HttpRequest(null, "http://localhost", null); _objHd4 = new Hd4(request, _ultimateConfig); bool result = _objHd4.DeviceWhatHas("design_dimensions", "101 x 44 x 16"); Dictionary<string, dynamic> reply = _objHd4.GetReply(); Assert.IsTrue(result); Assert.AreEqual(0, reply["status"]); Assert.AreEqual("OK", reply["message"]); dynamic jsonString = _jss.Serialize(reply["devices"]); Assert.AreEqual(true, Regex.IsMatch(jsonString, "Asus")); Assert.AreEqual(true, Regex.IsMatch(jsonString, "V80")); Assert.AreEqual(true, Regex.IsMatch(jsonString, "Spice")); Assert.AreEqual(true, Regex.IsMatch(jsonString, "S900")); Assert.AreEqual(true, Regex.IsMatch(jsonString, "Voxtel")); Assert.AreEqual(true, Regex.IsMatch(jsonString, "RX800")); }