コード例 #1
0
ファイル: MainTests.cs プロジェクト: hpkumbhar/XHRTool
 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(") }
     });
 }
コード例 #2
0
ファイル: MainTests.cs プロジェクト: hpkumbhar/XHRTool
        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);
        }
コード例 #3
0
ファイル: MainTests.cs プロジェクト: hpkumbhar/XHRTool
        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);
        }
コード例 #4
0
ファイル: MainTests.cs プロジェクト: hpkumbhar/XHRTool
        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);
        }
コード例 #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);
        }
コード例 #6
0
ファイル: MainTests.cs プロジェクト: hpkumbhar/XHRTool
        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);
        }
コード例 #7
0
ファイル: MainTests.cs プロジェクト: hpkumbhar/XHRTool
        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"));
        }