public void TestGetUriTrimStartSlash() { IApiRequest req = new VkApiRequest(); var need = "https://api.vk.com/method/test?v=5.16&lang=ru"; var result = req.GetUri("/test").ToString(); Assert.AreEqual(need, result); }
public void TestGetUriAppendAccessToken() { IApiRequest req = new VkApiRequest(); var result = req.GetUri("groups.get").ToString(); var need = "https://api.vk.com/method/groups.get?v=5.16&lang=ru&access_token=zzz"; Assert.AreEqual(need, result); }
public void TestGetUriParam() { IApiRequest req = new VkApiRequest(); var param = new NameValueCollection(); param.Add("id", "1"); var result = req.GetUri("test", param).ToString(); var need = "https://api.vk.com/method/test?id=1&v=5.16&lang=ru"; Assert.AreEqual(need, result); }
public async Task TestGetObjectOneObject() { var settProv= new ApiSettingsJsonFileProvider("Api/Settings/Vk.json"); var apiRequest = new VkApiRequest(); IApi api = new VkApi(apiRequest, settProv); var result = await api.Get<List<VkUser>>("users.get", "1"); Assert.AreEqual(1, result.Count); Assert.AreEqual(1, result[0].Id); Assert.AreEqual("durov", result[0].ScreenName); }
public async Task TestGetObjectVkList() { var settProv = new ApiSettingsJsonFileProvider("Api/Settings/Vk.json"); var apiRequest = new VkApiRequest(); IApi api = new VkApi(apiRequest, settProv); var result = await api.Get<VkList<VkPost>>("wall.get", "174111803"); Assert.AreEqual(305, result.Count); Assert.AreEqual(305, result.Items.Count); Assert.AreEqual(536, result.Items[0].Id); Assert.AreEqual(185202286, result.Items[0].FromId); }