示例#1
0
        public void GetGoogleNumberOfResults()
        {
            // SETUP
            GbrainAPI b = new GbrainAPI();

            // EXERCISE
            long results = b.GetNumerOfResults("this", "is", "a", "test");

            //ASSERT
            Assert.True(results > 5000000000);
        }
示例#2
0
        public object AccessGbrainAPIPrivateMethod(string methodName, object[] args)
        {
            GbrainAPI b = new GbrainAPI();

            var mi = b.GetType().GetMethod(methodName, System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);

            if (mi != null)
            {
                return(mi.Invoke(b, args));
            }
            return(null);
        }
示例#3
0
        public void GetNumberOfOccourrencesOfAnAnswerInGoogleSearch()
        {
            // SETUP
            GbrainAPI b        = new GbrainAPI();
            string    question = "chi ha vinto i mondiali del 2006?";
            string    answer   = "Italia";

            // EXERCISE
            long results = b.GetNumberOfOccourrences(question, answer);

            // ASSERT
            Assert.True(results > 5);
            //the assertion is that the number of result is greater than 5, as of now
            //(2019-02-16) there are 25 matches of the Word Italia inside the page
            //https://www.google.com/search?q=chi+ha+vinto+i+mondiali+del+2006
            //considering to mock the response of the method that gives the html back to make it deterministic
            //as of now it is not so due to its protection level
        }