Пример #1
0
        public void Test_GetBuffered()
        {
            MockApiClient.setAPIResponse(
                new ApiResponse(
                    200,
                    "{\"hash\":\"" + TestData.definition_hash + "\",\"created_at\":\"2011-12-13 14:15:16\",\"dpu\":10}",
                    200, 150));

            Definition def = new Definition(m_user, TestData.definition);
            Assert.AreEqual(TestData.definition, def.get(), "Definition CSDL not set correctly");
            Assert.AreEqual(TestData.definition_hash, def.getHash(), "Incorrect hash");

            MockApiClient.setAPIResponse(
                new ApiResponse(
                    200,
                    "{\"stream\":[{\"interaction\":{\"source\":\"Snaptu\",\"author\":{\"username\":\"nittolexia\",\"name\":\"nittosoetreznoe\",\"id\":172192091,\"avatar\":\"http://a0.twimg.com/profile_images/1429378181/gendowor_normal.jpg\",\"link\":\"http://twitter.com/nittolexia\"},\"type\":\"twitter\",\"link\":\"http://twitter.com/nittolexia/statuses/89571192838684672\",\"created_at\":\"Sat, 09 Jul 2011 05:46:51 +0000\",\"content\":\"RT @ayyuchadel: Haha RT @nittolexia: Mending gak ush maen twitter dehh..RT @sansan_arie:\",\"id\":\"1e0a9eedc207acc0e074ea8aecb2c5ea\"},\"twitter\":{\"user\":{\"name\":\"nittosoetreznoe\",\"description\":\"f**k all\",\"location\":\"denpasar, bali\",\"statuses_count\":6830,\"followers_count\":88,\"friends_count\":111,\"screen_name\":\"nittolexia\",\"lang\":\"en\",\"time_zone\":\"Alaska\",\"id\":172192091,\"geo_enabled\":true},\"mentions\":[\"ayyuchadel\",\"nittolexia\",\"sansan_arie\"],\"id\":\"89571192838684672\",\"text\":\"RT @ayyuchadel: Haha RT @nittolexia: Mending gak ush maen twitter dehh..RT @sansan_arie:\",\"source\":\"<a href=\\\"http://www.snaptu.com\\\" rel=\\\"nofollow\\\">Snaptu</a>\",\"created_at\":\"Sat, 09 Jul 2011 05:46:51 +0000\"},\"klout\":{\"score\":45,\"network\":55,\"amplification\":17,\"true_reach\":31,\"slope\":0,\"class\":\"Networker\"},\"peerindex\":{\"score\":30},\"language\":{\"tag\":\"da\"}}]}",
                    200, 150));

            Interaction[] interactions = def.getBuffered();
            Assert.AreEqual("nittosoetreznoe", interactions[0].getStringVal("twitter.user.name"), "The Twitter username is incorrect");
            Assert.AreEqual(89571192838684672, interactions[0].getLongVal("twitter.id"), "The Twitter ID is incorrect");
            Assert.AreEqual("http://a0.twimg.com/profile_images/1429378181/gendowor_normal.jpg", interactions[0].getStringVal("interaction.author.avatar"), "The author avatar is incorrect");
        }