Esempio n. 1
0
        public async Task Core_Net_HttpRequestGet_SendAsync()
        {
            var    configuration = new ConfigurationManagerCore(ApplicationTypes.Native);
            object dataOut       = null;
            var    request       = new HttpRequestGet <object>(configuration.AppSettingValue("MyWebService") + "/HomeApi");

            try
            {
                dataOut = await request.SendAsync();

                Assert.IsTrue(request.Response.IsSuccessStatusCode);
                throw new HttpRequestException();
            }
            catch (HttpRequestException ex)
            {
                Assert.IsTrue(dataOut != null || ex.Message.Contains("No such host") || ex.Message.Contains("no data"));
            }
            finally
            {
                request.Dispose();
            }
        }
Esempio n. 2
0
        public async Task Net_HttpRequestGet_SendAsync()
        {
            var    configuration = ConfigurationManagerSafeTests.ConfigurationManagerSafeConstruct();
            object dataOut       = null;
            var    request       = new HttpRequestGet <object>(configuration.AppSettingValue("MyWebService") + "/HomeApi");

            try
            {
                dataOut = await request.SendAsync();

                Assert.IsTrue(request.Response.IsSuccessStatusCode);
                throw new WebException();
            }
            catch (WebException)
            {
                Assert.IsTrue(dataOut != null);
            }
            finally
            {
                request.Dispose();
            }
        }