Пример #1
0
        public void GetRightFilmTitle()
        {
            HttpClient       client           = new HttpClient();
            FilmDeserializer filmDeserializer = new FilmDeserializer();
            FilmHandler      filmHandler      = new FilmHandler(client, filmDeserializer);
            Film             film             = filmHandler.Handle(HttpMethod.Get, "https://ghibliapi.herokuapp.com/films/578ae244-7750-4d9f-867b-f3cd3d6fecf4", null, null);

            Assert.AreEqual("The Tale of the Princess Kaguya", film.title, "Wrong title");
        }
Пример #2
0
        static void UI(HttpClient client)
        {
            while (true)
            {
                Console.WriteLine("Type number to choose command:");
                Console.WriteLine("1. Show all films id and title");
                Console.WriteLine("2. Show film by id");
                Console.WriteLine("3. Show all people id and name");
                Console.WriteLine("4. Show people by id");
                Console.WriteLine("5. End program");

                var command = Console.ReadLine();

                switch (command)
                {
                case "1":
                    FilmsDeserializer filmsParser  = new FilmsDeserializer();
                    FilmsHandler      filmsHandler = new FilmsHandler(client, filmsParser);
                    WriteAllFilmsIdAndTitle(filmsHandler.Handle(HttpMethod.Get, GHIBLI_SITE + "films", null, null));
                    break;

                case "2":
                    Console.WriteLine("Enter film id:");
                    var filmId = Console.ReadLine();
                    FilmDeserializer filmParser  = new FilmDeserializer();
                    FilmHandler      filmHandler = new FilmHandler(client, filmParser);
                    filmHandler.Handle(HttpMethod.Get, $"{GHIBLI_SITE}films/{filmId}", null, null).WriteFilm(client);
                    break;

                case "3":
                    AllPeopleDeserializer allPeopleDeserializer = new AllPeopleDeserializer();
                    AllPeopleHandler      allPeopleHandler      = new AllPeopleHandler(client, allPeopleDeserializer);
                    WriteAllPeopleIdAndName(allPeopleHandler.Handle(HttpMethod.Get, GHIBLI_SITE + "people", null, null));
                    break;

                case "4":
                    Console.WriteLine("Enter people id:");
                    var peopleId = Console.ReadLine();
                    PeopleDeserializer peopleDeserializer = new PeopleDeserializer();
                    PeopleHandler      peopleHandler      = new PeopleHandler(client, peopleDeserializer);
                    peopleHandler.Handle(HttpMethod.Get, $"{GHIBLI_SITE}people/{peopleId}", null, null).WritePeople();
                    break;

                case "5":
                    return;

                default:
                    Console.WriteLine("Wrong option! Try again.");
                    break;
                }

                Console.WriteLine();
            }
        }