Ejemplo n.º 1
0
 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(") }
     });
 }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
        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"));
        }