Esempio n. 1
0
        public async Task SetSyncPost()
        {
            var init = Substitute.For<IHttpInitializer>();
            var messager = new FakeMessageHandler(new HttpResponseMessage());
            init.HttpClient.Returns(new HttpClient(messager));
            var rest = new RestClient(init);
            var config = new HttpConfiguration(
                new Uri("http://happy.ca/"), "route", HttpRequest.Post) { Data = "data" };

            var ads = await rest.SetAsync(config, response =>
                new List<Ad> { new Ad { AdID = Int32.MaxValue } });

            Assert.AreEqual(1, ads.Count(x => x.AdID == Int32.MaxValue));
            Assert.AreEqual("http://happy.ca/route", messager.RequestMessage.RequestUri.AbsoluteUri);
            Assert.AreEqual(HttpMethod.Post, messager.RequestMessage.Method);
        }