コード例 #1
0
        public void TestSentimentDocumentLevel()
        {
            var input = new SentimentRequest {
                text = "Love is a canvas furnished by Nature and embroidered by imagination."
            };

            var resp = _subject.PostRequest <SentimentResponse, SentimentRequest>(input, "/v1/sentiment", new AnalysisCell {
                Address = "A1", Text = input.text
            });

            Assert.IsNotNull(resp.Result);
            Assert.IsTrue(resp.Result.Success);

            Assert.IsTrue(resp.Result.Remaining > 0);
            Assert.IsTrue(resp.Result.Limit > 0);
        }
コード例 #2
0
        public void TestRateLevelFailsWrongMethod()
        {
            var resp = _subject.PostRequest <RateResponse>("/rate_limit");

            resp.Wait();
            Assert.IsNotNull(resp.Result);
            Assert.IsFalse(resp.Result.Success);
            Assert.IsTrue(resp.Result.ErrorMessage.Contains("405"));
        }
コード例 #3
0
        public void TestInvalidCredentials()
        {
            var subject = new RestBase("test", "test", "http://api.theysay.io");

            var input = new SentimentRequest {
                text = "Love is a canvas furnished by Nature and embroidered by imagination."
            };

            var resp = subject.PostRequest <SentimentResponse, SentimentRequest>(input, "/v1/sentiment", new AnalysisCell {
                Address = "A1", Text = input.text
            });

            resp.Wait();
            Assert.IsNotNull(resp.Result);
            Assert.IsFalse(resp.Result.Success);
            Assert.IsNotNull(resp.Result.ErrorMessage);
            Assert.IsTrue(resp.Result.ErrorMessage.Contains("401"));
        }