public void SandboxTest() { var m = new XHRLogicManager(); var ret = m.SendXHR(new XHRRequestModel { Url = "http://www.google.com/", Verb = HttpMethod.Get, //Headers = new List<HttpHeader>{ new HttpHeader(") } }); }
public void GetInvalidUrl() { var m = new XHRLogicManager(); var returnMessage = m.SendXHR(new XHRRequestModel { Url = "http://localhost:2032/api/v1alues", Verb = HttpMethod.Get }); Assert.IsNotNull(returnMessage); Assert.AreEqual(returnMessage.StatusCode, HttpStatusCode.NotFound); }
public void GetInvalidUrlLocalActiveRefuse() { var m = new XHRLogicManager(); var returnMessage = m.SendXHR(new XHRRequestModel { Url = "http://localhost:10034/api/values", Verb = HttpMethod.Get }); Assert.IsNotNull(returnMessage); Assert.AreEqual(returnMessage.StatusCode, default(HttpStatusCode)); Assert.IsNotNull(returnMessage.Content); }
public void SimpleGet() { var m = new XHRLogicManager(); var returnMessage = m.SendXHR(new XHRRequestModel { Url = "http://localhost:2032/api/values", Verb = HttpMethod.Get }); Assert.IsNotNull(returnMessage); Assert.AreEqual(returnMessage.StatusCode, HttpStatusCode.OK); Assert.IsNotNull(returnMessage.Content); }
private void MakeRequestCommand_OnExecuted(object sender, ExecutedRoutedEventArgs e) { var currentUrlHistoryItem = getCurrentUrlHistoryModel(); if (!UrlHistory.Contains(currentUrlHistoryItem, urlHistoryModelEqualityComparer)) { UrlHistory.Insert(0, currentUrlHistoryItem); saveHistory(); } CurrentRequestViewModel.Headers = CurrentRequestViewModel.UIHeaders.Where(h => h.IsSelected).Select(h => new HttpHeader(h.Name, h.Value)).ToList(); _MainWindow.IsEnabled = false; new Action(() => CurrentResponseViewModel = xhrLogicManager.SendXHR(CurrentRequestViewModel)).BeginInvoke((ar => Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() => _MainWindow.IsEnabled = true))), null); }
public void SimplePostNoMediaType() { var m = new XHRLogicManager(); var returnMessage = m.SendXHR(new XHRRequestModel { Url = "http://localhost:2032/api/values/PostTest", Verb = HttpMethod.Post, Content = "{Value1 : Test1, Value2 : Test2}", Headers = new List <HttpHeader> { new HttpHeader("X-Test", "TestHeader Val") } }); Assert.IsNotNull(returnMessage); Assert.AreEqual(HttpStatusCode.UnsupportedMediaType, returnMessage.StatusCode); }
public void SimplePost() { var m = new XHRLogicManager(); var returnMessage = m.SendXHR(new XHRRequestModel { Url = "http://localhost:2032/api/values/PostTest", Verb = HttpMethod.Post, Content = "{Value1 : Test1, Value2 : Test2}", Headers = new List <HttpHeader> { new HttpHeader("X-Test", "TestHeader Val"), new HttpHeader("Content-Type", "application/json") } }); Assert.IsNotNull(returnMessage); Assert.AreEqual(HttpStatusCode.OK, returnMessage.StatusCode); Assert.IsNotNull(returnMessage.Content.Contains("T1")); }