public void TestSetTopHashtags()
        {
            Root       root  = getData.GetTweeterRootData();
            TweetStats stats = new TweetStats(root, new List <Emoji>(), new RunningTotals());

            stats.SetTopHashtags();
            Assert.IsTrue(stats.TopHashtagList.Count > 0);
        }
        public void TestSetPctTweetsWithUrl()
        {
            Root       root  = getData.GetTweeterRootData();
            TweetStats stats = new TweetStats(root, new List <Emoji>(), new RunningTotals());

            stats.SetPctTweetsWithUrl();
            Assert.IsTrue(stats.PctTweetsWithUrl > 0);
        }
        public void TestTweetStatsSetAverageTimes()
        {
            TweetStats stats = new TweetStats();

            stats.TotalDownloadTimeInMiliSeconds = 10000;
            stats.TotalTweetsReceived            = 139;
            stats.SetAverageTimes();
            Assert.IsTrue(stats.AverageTweetsReceivedPerSecond > 0);
        }
Ejemplo n.º 4
0
    // Fetches the user stats data from the server, before populating the polarity graph.
    // Fetched user stats are cached for easy switching between polarity and types view.
    public IEnumerator Initialise(string username)
    {
        this.username = username;

        CompoundButton polarityBtn = transform.Find("PolarityButton").GetComponent <CompoundButton>();
        CompoundButton typesBtn    = transform.Find("TypesButton").GetComponent <CompoundButton>();

        polarityBtn.MainCollider.enabled = false;
        typesBtn.MainCollider.enabled    = false;

        transform.Find("Username").GetComponent <TextMesh>().text = "@" + username;

        UnityWebRequest req = UnityWebRequest.Get(string.Format("{0}/user_stats/?username={1}"
                                                                , Commons.dataURL, username));

        req.SendWebRequest();

        while (!req.isDone)
        {
            yield return(null);
        }
        if (req.isHttpError || req.isNetworkError)
        {
            Debug.Log(req.error);
            yield break;
        }

        TweetStats stats = JSONParser.parseJSONObject <TweetStats>(req.downloadHandler.text);

        userStats = stats.User_Stats;
        aggrStats = stats.Aggregate_Stats;

        DisplayPolarity();

        polarityBtn.MainCollider.enabled = true;
        typesBtn.MainCollider.enabled    = true;
    }