Exemplo n.º 1
0
        public void GetRestaurantsByOutcode_Returns_Data_For_The_Outcode_SE19()
        {
            // Given a guaranteed succesful api call
            var outcode = "SE19";

            // When we call the service method
            var restaurantService = new RestaurantService(new JustEatRestClientFactory(), new JustEatRestRequestFactory());
            var actual = restaurantService.GetRestaurantsByOutcode(outcode);

            // Then the restaurant list is not empty
            actual.Count.Should().BeGreaterThan(0);
        }
Exemplo n.º 2
0
        public void GetRestaurantsByOutcode_Returns_Empty_List_When_API_Call_Fails()
        {
            // Given a failed api call, regardless of restaurant data returned
            var outcode = "";
            var restaurantDataRoot = new RestaurantDataRoot();
            var fakedRestClient = createFakedRestClient(restaurantDataRoot, HttpStatusCode.NotFound);
            var fakedRestClientFactory = createFakeRestClientFactory(fakedRestClient);

            // When we call the service method
            var restaurantService = new RestaurantService(fakedRestClientFactory, new JustEatRestRequestFactory());
            var actual = restaurantService.GetRestaurantsByOutcode(outcode);

            // Then the restaurant list is empty
            var expected = new List<Restaurant>();
            actual.ShouldBeEquivalentTo(expected);
        }
Exemplo n.º 3
0
        public void GetRestaurantsByOutcode_Returns_Correct_Data_When_API_Call_Succeeds()
        {
            // Given a guaranteed succesful api call
            var outcode = "SE19";
            var restaurantDataRoot = createRestaurantDataRoot();
            var fakedRestClient = createFakedRestClient(restaurantDataRoot, HttpStatusCode.OK);
            var fakedRestClientFactory = createFakeRestClientFactory(fakedRestClient);

            // When we call the service method
            var restaurantService = new RestaurantService(fakedRestClientFactory, new JustEatRestRequestFactory());
            var actual = restaurantService.GetRestaurantsByOutcode(outcode);

            // Then the restaurant list is as expected
            var expected = restaurantDataRoot.Restaurants;
            actual.ShouldBeEquivalentTo(expected);
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            var outcode = string.Empty;
            while (true)
            {
                Console.WriteLine();
                Console.WriteLine("Type your outcode and press return, (0 to exit)");
                outcode = Console.ReadLine();
                Console.WriteLine();
                if (outcode == "0") break;

                var restaurantService = new RestaurantService(new JustEatRestClientFactory(), new JustEatRestRequestFactory());
                var restaurants = restaurantService.GetRestaurantsByOutcode(outcode);

                restaurants.ForEach(restaurant => displayRestaurant(restaurant));
            }
        }