コード例 #1
0
        public void TestApiNoKeyGiven()
        {
            var response = GopApiHelper.Execute(
                "http://content.guardianapis.com/",
                "search",
                null,
                null,
                null);

            Assert.AreEqual(response.message.Value, "No API key found in headers or querystring");
        }
コード例 #2
0
        public void TestInvalidApiKeyWithoutFilter()
        {
            var response = GopApiHelper.Execute(
                "http://content.guardianapis.com/",
                "search",
                "InvalidKey",
                null,
                null);

            Assert.AreEqual(response.message.Value, "Invalid authentication credentials");
        }
コード例 #3
0
        public void TestApiAvailability()
        {
            var response = GopApiHelper.Execute(
                "http://content.guardianapis.com/",
                "search",
                "30c5a1f2-3132-4f94-bba1-38b397fdec67",
                null,
                null);

            Assert.AreEqual(response.response.status.Value, "ok");
        }
コード例 #4
0
        public void TestSearchBySection()
        {
            var response = GopApiHelper.Execute(
                "http://content.guardianapis.com/",
                "search",
                "30c5a1f2-3132-4f94-bba1-38b397fdec67",
                null,
                new SectionFilter("world"));

            Assert.AreEqual(response.response.status.Value, "ok");
        }
コード例 #5
0
        public void TestSearchByDate()
        {
            var response = GopApiHelper.Execute(
                "http://content.guardianapis.com/",
                "search",
                "30c5a1f2-3132-4f94-bba1-38b397fdec67",
                null,
                new DateFilter(new DateTime(2017, 9, 17)));

            Assert.AreEqual(response.response.status.Value, "ok");
        }
コード例 #6
0
        public void TestSearchByInvalidDate()
        {
            var response = GopApiHelper.Execute(
                "http://content.guardianapis.com/",
                "search",
                "30c5a1f2-3132-4f94-bba1-38b397fdec67",
                null,
                new Filter("to-date")
            {
                Value = "null"
            });

            Assert.AreEqual(response.response.status.Value, "error");
        }