public void Restaurant_Should_Map_To_RestaurantViewModel()
        {
            // Arrange
            var restaurant = new Restaurant
            {
                Logo = new List<Logo>
                {
                    new Logo
                    {
                        StandardResolutionURL = "/Images/je-logo.png"
                    }
                },
                Name = "Test Restaurant",
                RatingStars =  4.72,
                CuisineTypes = new List<CuisineType>
                {
                   new CuisineType{Name = "Chinese"},
                   new CuisineType {Name = "Thai"}
                }
            };

            var cuisineStrings = restaurant.CuisineTypes.Select(c => c.Name).ToArray();
            var delimitedCuisine = string.Join(", ", cuisineStrings);

            // Act
            var restaurantViewModel = new RestaurantViewModel(restaurant);

            // Assert
            Assert.AreEqual(restaurantViewModel.CuisineTypes, delimitedCuisine);
            Assert.AreEqual(restaurantViewModel.Name, restaurant.Name);
            Assert.AreEqual(restaurantViewModel.Rating, restaurant.RatingStars);
        }
Esempio n. 2
0
 public RestaurantViewModel(Restaurant restaurant)
 {
     Logo = restaurant.Logo != null && restaurant.Logo.Any() ? restaurant.Logo.First().StandardResolutionURL : "/Images/je-logo.png";
     Name = restaurant.Name;
     Rating = restaurant.RatingStars;
     NumberOfRatings = restaurant.NumberOfRatings;
     CuisineTypes = restaurant.CuisineTypes != null && restaurant.CuisineTypes.Any() ? string.Join(", ", restaurant.CuisineTypes.Select(c => c.Name).ToArray()) : "";
     Address = restaurant.Address + ", " + restaurant.City + ", " + restaurant.Postcode;
     IsOpenNow = restaurant.IsOpenNow;
 }