public void Setup()
        {
            var token   = new AccessToken();
            var handler = new FakeResponseHandlerByHost();

            handler.AddFakeResponse(new Uri($"https://api.vk.com/method/wall.get?"),
                                    new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new ByteArrayContent(Resources.FakeWallGetResponse)
            });

            var vkApi = new vk.Models.VkApi.VkApi(token, handler);

            _apiProvider = new VkApiProvider(token, vkApi);
        }
Example #2
0
        public async Task FakeResponseByHost_pass_invalid_host_fail_expected()
        {
            var handler = new FakeResponseHandlerByHost();

            var contentToCompare = "boop";

            handler.AddFakeResponse(new Uri("http://whatever.org/method=doesnotmatter?param=39&value=2"),
                                    new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(contentToCompare)
            });

            var httpClient = new HttpClient(handler);
            var result     = await httpClient.GetAsync(new Uri("http://notwhatever.org/"));

            Assert.That(result.IsSuccessStatusCode, Is.False);
        }