Example #1
0
        public void InterpretClient_WithValidInput_ReturnsExpectedObjectType()
        {
            InterpreterContext     interpreterContext     = new InterpreterContext();
            RestaurantSearchClient restaurantSearchClient = new RestaurantSearchClient(interpreterContext);
            string searchSentence = string.Format("restaurant by location '{0}'", "str.Caracal");
            var    intercept      = restaurantSearchClient.Intercept(searchSentence);

            Assert.IsInstanceOf(typeof(List <RestaurantModel>), intercept);
        }
Example #2
0
        public void InterpretClient_WithValidInput_IsNotEmpty()
        {
            InterpreterContext     interpreterContext     = new InterpreterContext();
            RestaurantSearchClient restaurantSearchClient = new RestaurantSearchClient(interpreterContext);
            string searchSentence = string.Format("restaurant by location '{0}'", "str.Caracal");
            var    intercept      = restaurantSearchClient.Intercept(searchSentence);

            Assert.IsNotEmpty(intercept.ToString());
        }
Example #3
0
        public string RestaurantSearch()
        {
            InterpreterContext     context = new InterpreterContext();
            RestaurantSearchClient client  = new RestaurantSearchClient(context);

            Console.WriteLine("Search Restaurant by location");
            Console.WriteLine("Enter Location:");
            var    location       = Console.ReadLine();
            string searchSentence = string.Format("restaurant by location '{0}'", location);
            var    result         = client.Intercept(searchSentence);

            if (!result.Any())
            {
                Console.WriteLine("Sorry, no restaurants available in this location.");
            }


            string restaurantID = String.Empty;

            if (result.Any())
            {
                Console.WriteLine("List of Restaurants");
                Console.WriteLine("**********************************");

                foreach (var item in result)
                {
                    Console.WriteLine(" ");
                    Console.WriteLine("{0} {1}", item.RestaurantID, item.Name);
                    Console.WriteLine("{0}", item.Address);
                    int rating = item.Rating;
                    Console.Write("Rating: ");
                    while (rating > 0)
                    {
                        Console.Write("*");
                        rating--;
                    }

                    Console.WriteLine("");
                    Console.WriteLine("_________________________________");
                }

                Console.WriteLine();
                Console.WriteLine("Please select the restaurant by ID: ");
                restaurantID = Console.ReadLine();
            }
            return(restaurantID);
        }