Exemple #1
0
        public void getJSON()
        {
            ApiEngine ae   = new ApiEngine(new Config());
            string    json = ae.getJson();

            Assert.IsFalse(String.IsNullOrEmpty(json));

            JavaScriptSerializer jss = new JavaScriptSerializer();

            HubbleJSON hubble_json = jss.Deserialize <HubbleJSON>(json);

            Assert.IsFalse(String.IsNullOrEmpty(hubble_json.name));
            Assert.IsFalse(String.IsNullOrEmpty(hubble_json.os_version));
            Assert.IsFalse(String.IsNullOrEmpty(hubble_json.client_version));
            Assert.IsFalse(String.IsNullOrEmpty(hubble_json.ram_total));
            Assert.IsFalse(String.IsNullOrEmpty(hubble_json.ram_free));
            Assert.IsFalse(String.IsNullOrEmpty(hubble_json.cpu_usage));
        }
Exemple #2
0
        public string getJson()
        {
            List <Drive> drives = sie.getDrivesInfo();
            HubbleJSON   data   = new HubbleJSON(drives.Count);

            data.name           = sie.getName();
            data.os_version     = sie.getOS();
            data.ram_free       = sie.getFreeRam();
            data.ram_total      = sie.getTotalRam();
            data.cpu_usage      = sie.getCpuUsage();
            data.client_version = conf.getCfg("app_version");

            int i = 0;

            foreach (Drive drive in drives)
            {
                data.drives[i] = drive;
                i++;
            }
            JavaScriptSerializer jss = new JavaScriptSerializer();

            return(jss.Serialize(data));
        }