コード例 #1
0
        public void TopThreeTest()
        {
            Restaurant res1 = new Restaurant("Burger King", 1);
            Restaurant res2 = new Restaurant("McDonalds", 2);
            Restaurant res3 = new Restaurant("Wendys", 3);
            Restaurant res4 = new Restaurant("Checkers", 4);

            Reviewer reviewer = new Reviewer("Cooper", "*****@*****.**");

            reviewer.MakeReview(4.35m, res1, "I really liked it");
            reviewer.MakeReview(3.67m, res2, "It was ok");
            reviewer.MakeReview(4.87m, res3, "Sooooo good");
            reviewer.MakeReview(2.34m, res4, "holy crap so bad");



            List <Restaurant> myList = new List <Restaurant>();

            myList.Add(res1);
            myList.Add(res2);
            myList.Add(res3);
            myList.Add(res4);

            List <Restaurant> sortedList = RestaurantListMethods.TopThree(myList);


            int expected = 0;

            int actual = sortedList.IndexOf(res3);


            Assert.AreEqual(expected, actual);
        }
        public ViewResult Show(int id)
        {
            Restaurant res = resCrud.GetRestaurantById(id);
            RestaurantLibrary.CRUD.ReviewerCRUD reviewerCRUD = new RestaurantLibrary.CRUD.ReviewerCRUD();
            RestaurantListMethods restListMethods = new RestaurantListMethods();

            ViewData["reviewers"] = reviewerCRUD.GetAllReviewers();
            ViewData["restaurant_id"] = id;
            ViewData["restaurant_reviews"] = res.Reviewlist;
            ViewData["restaurant"] = res;
            ViewBag.restaurant = res;
            
            return View("view");

        }
コード例 #3
0
        public void SortRestaurantByIdTest()
        {
            Restaurant        res1   = new Restaurant("Burger King", 1);
            Restaurant        res2   = new Restaurant("McDonalds", 2);
            Restaurant        res3   = new Restaurant("Wendys", 3);
            List <Restaurant> myList = new List <Restaurant>();

            myList.Add(res1);
            myList.Add(res2);
            myList.Add(res3);

            Restaurant foundRes = RestaurantListMethods.GetRestaurantById(myList, 1);


            string expected = "Burger King";

            string actual = foundRes.Name;

            Assert.AreEqual(actual, expected);
        }
コード例 #4
0
        static void Main(string[] args)
        {
            //Restaurant res = new Restaurant("Papa Johns");

            //RestaurantSerializer resSerializer = new RestaurantSerializer();

            //resSerializer.SerializeMethod(res, "restaurant2");

            //RestaurantDeserializer resDeserializer = new RestaurantDeserializer();

            //Console.WriteLine(resDeserializer.DeserializeMethod("restaurant2").AverageRating);

            //Console.ReadKey();



            //Logger log = LogManager.GetCurrentClassLogger();
            //log.Info("Starting application");

            //// start application
            //Console.WriteLine("Welcome to the world of restaurants");
            //Console.WriteLine("-----------------------------------");
            //Console.WriteLine();

            //// display menu
            //Console.WriteLine("Here are your options bud: ");
            //Console.WriteLine("\"ViewRev\" (View all restaurants)");
            //Console.WriteLine("\"TopThree\" (Return the top 3 restaurants)");
            //Console.WriteLine("\"ViewRes\" (View a reviews)");
            //Console.WriteLine("\"AddRes\" (Add a restaurant)");



            //Console.Write("Your input: ");
            //String input = Console.ReadLine().ToLower();


            //while(input != "quit")
            //{
            //    if(input == "viewres")
            //    {
            //        Console.WriteLine("How would you like to find the restaurant?");
            //    }
            //    else if(input != "viewres" && input != "topthree" && input != "viewrev" && input != "addres")
            //    {
            //        Console.WriteLine("You messed up bud. Please enter either \"ViewRev\", \"TopThree\", \"ViewRes\", or \"AddRes\"");
            //        Console.Write("<input> ");
            //        input = Console.ReadLine().ToLower();
            //        log.Info(input);

            //    }

            //}

            //// end application
            //Console.WriteLine("peace out dude");

            RestaurantCRUD resCrud = new RestaurantCRUD();
            List <RestaurantLibrary.Models.Restaurant> resList = new List <RestaurantLibrary.Models.Restaurant>(RestaurantListMethods.CreateRestaurantList(resCrud.GetRestaurant()));

            foreach (RestaurantLibrary.Models.Restaurant res in resList)
            {
                Console.WriteLine(res.Name);
                Console.WriteLine(res.AverageRating);
                Console.WriteLine(res.Location);
                res.getAllReviews();
            }
            ;

            RestaurantListMethods.TopThree(resList);
            RestaurantListMethods.SortByNameAscending(resList);
            RestaurantListMethods.SortByNameDescending(resList);

            Console.ReadKey();
        }