public void GetTopThree_AssertIsEqual()
        {
            var service = new RestaurantService(_moqRepo.Object);
            var rList   = service.GetTopThreeRestaurants();

            CollectionAssert.AreEqual(rList, _moqRepo.Object.GetAll().OrderByDescending(x => x.AvgRating).Take(3).ToList());
        }
        public void GetRestaurantsByOrder_PassedInvalid_AssertDefault()
        {
            var service = new RestaurantService(_moqRepo.Object);
            var rList   = service.GetRestaurantsByOrder("lmao");

            CollectionAssert.AreEqual(rList, new List <Restaurant>());
        }
        public void GetRestaurantsBySearch_PassedAString_AssertCollectionsEqual()
        {
            var service = new RestaurantService(_moqRepo.Object);
            var rList   = service.SearchRestaurants("Z");

            CollectionAssert.AreEqual(rList, _moqRepo.Object.GetAll().Where(x => Regex.IsMatch(x.Name, "Z")).ToList());
        }
        public void GetRestaurantsByOrder_PassedState_AssertState()
        {
            var service = new RestaurantService(_moqRepo.Object);
            var rList   = service.GetRestaurantsByOrder("State");

            CollectionAssert.AreEqual(rList, _moqRepo.Object.GetAll().OrderBy(x => x.State).ToList());
        }
        public void GetRestaurantsByOrder_PassedRating_AssertRating()
        {
            var service = new RestaurantService(_moqRepo.Object);
            var rList   = service.GetRestaurantsByOrder("Rating");

            CollectionAssert.AreEqual(rList, _moqRepo.Object.GetAll().OrderByDescending(x => x.AvgRating).ToList());
        }
        public void GetRestaurantsByOrder_PassedCity_AssertCity()
        {
            var service = new RestaurantService(_moqRepo.Object);
            var rList   = service.GetRestaurantsByOrder("City");

            CollectionAssert.AreEqual(rList, _moqRepo.Object.GetAll().OrderBy(x => x.City).ToList());
        }
        public void GetRestaurantsByOrder_PassedAddress_AssertAddress()
        {
            var service = new RestaurantService(_moqRepo.Object);
            var rList   = service.GetRestaurantsByOrder("AdDress");

            CollectionAssert.AreEqual(rList, _moqRepo.Object.GetAll().OrderBy(x => x.Address).ToList());
        }
Beispiel #8
0
        protected override void PopulateEntity(Reservation reservation, ReservationAddEditViewModel model)
        {
            reservation.Id              = model.Id;
            reservation.UserId          = model.UserId;
            reservation.RestaurantId    = model.RestaurantId;
            reservation.Comment         = model.Comment;
            reservation.PeopleCount     = model.PeopleCount;
            reservation.ReservationTime = model.ReservationTime;

            ReservationService service     = new ReservationService();
            RestaurantService  restService = new RestaurantService();

            reservation.RestaurantName = restService.GetById((model.RestaurantId)).Name;

            if (!service.CheckFreeSeats(reservation))
            {
                ModelState.AddModelError("PeopleCount", "There are no free seats");
                model.Restaurants = GetRestaurants();
                //return View(model);
            }
            else
            {
                service.Save(reservation);
                // return RedirectToAction("Index");
            }
        }
        public void TestSearchByName()
        {
            // Arrange
            List <Restaurant> restaurants = new List <Restaurant>();
            string            json        = System.IO.File.ReadAllText(@"C:\revature\" +
                                                                       @"hayes-timothy-project0\LocalGourmet\LocalGourmet.BLL\" +
                                                                       @"Configs\RestaurantsForUnitTest2.json");

            restaurants = Serializer.Deserialize <List <Restaurant> >(json);

            // Act
            string            s1 = "sub";
            List <Restaurant> a1 = (List <Restaurant>)RestaurantService.SearchByName(RestaurantService.GetAllFromJSON(), s1);

            string            s2 = "CO";
            List <Restaurant> a2 = (List <Restaurant>)RestaurantService.SearchByName(RestaurantService.GetAllFromJSON(), s2);

            // Assert
            Assert.AreEqual("Subway", a1[0].Name);
            Assert.AreEqual(1, a1.Count);

            Assert.AreEqual("Three Coins Diner", a2[0].Name);
            Assert.AreEqual("Tampa Bay Brewing Company", a2[1].Name);
            Assert.AreEqual("Columbia Restaurant", a2[2].Name);
            Assert.AreEqual(3, a2.Count);
        }
        public void TestGetTop3()
        {
            // Arrange
            List <Restaurant> restaurants = new List <Restaurant>();
            string            json        = System.IO.File.ReadAllText(@"C:\revature\" +
                                                                       @"hayes-timothy-project0\LocalGourmet\LocalGourmet.BLL\" +
                                                                       @"Configs\RestaurantsForUnitTest2.json");

            restaurants = Serializer.Deserialize <List <Restaurant> >(json);

            // Act
            List <Restaurant> expected = new List <Restaurant>();

            expected.Add(restaurants[1]);
            expected.Add(restaurants[2]);
            expected.Add(restaurants[7]);
            IEnumerable <Restaurant> actual     = RestaurantService.GetTop3(RestaurantService.GetAllFromJSON());
            IEnumerator <Restaurant> actualEnum = actual.GetEnumerator();

            // Assert
            actualEnum.MoveNext();
            Assert.AreEqual(expected[0].ToString(), actualEnum.Current.ToString());
            actualEnum.MoveNext();
            Assert.AreEqual(expected[1].ToString(), actualEnum.Current.ToString());
            actualEnum.MoveNext();
            Assert.AreEqual(expected[2].ToString(), actualEnum.Current.ToString());
            actualEnum.Dispose();
        }
 /// <summary>
 /// Method to Send Order Status to Waiter Client
 /// </summary>
 /// <param name="order">customer order data</param>
 public static void SendOrderStatus(RestaurantService.Contracts.CustomerOrder order)
 {
     foreach (KeyValuePair<Guid, INotifyOrderStatusCallback> obj in registeredWaiters)
     {
         obj.Value.OnOrderNotification(order);
     }
 }
        public IHttpActionResult Get(int id)
        {
            RestaurantService restaurantService = CreateRestaurantService();
            var restaurant = restaurantService.GetRestaurantById(id);

            return(Ok(restaurant));
        }
Beispiel #13
0
        //Load Item Button
        private void button5_Click(object sender, EventArgs e)
        {
            String name     = RestaurantName.Text.ToString();
            String location = RestaurantLocation.Text.ToString();

            if (fieldCheckForRestaurant(name, location))
            {
                Restaurant restaurant = new Restaurant();
                restaurant.Name     = name;
                restaurant.Location = location;
                RestaurantService restaurantService = new RestaurantService();
                if (restaurantService.GetByLocation(restaurant) == "exist")
                {
                    int RID = restaurantService.GetRID(restaurant);
                    Load.Text = name + '-' + location;
                    cellFlag  = false;
                    LoadItem(RID);
                }
                else if (restaurantService.GetByLocation(restaurant) == "non-exist")
                {
                    MessageBox.Show("Restaurant Doesn't Exist!");
                }
            }
            else
            {
                MessageBox.Show("To load item kindly provide the restaurant name and location!");
            }
        }
Beispiel #14
0
        public async Task E_Update_EditNameRestaurant_NameRestaurantChangeInDb()
        {
            //Arrange
            var restaurantService = new RestaurantService();
            var restaurant        = new Restaurant()
            {
                ID = new Guid("10000000-0000-0000-0000-000000000000"), Name = "TestUpgarde", Grade = new Grade()
                {
                    Score = 1
                }
            };

            restaurantsToDelete.Add(restaurant);
            restaurantService.Create(restaurantsToDelete.First());

            restaurant.Name           = "updateTest";
            restaurant.Grade.Score    = 5;
            restaurant.Address.Street = "test";

            //Act
            await restaurantService.Update(restaurant);

            var updateResto = restaurantService.GetAll().Where(e => e.ID == restaurant.ID).FirstOrDefault();

            //Assert
            Assert.AreEqual(restaurant.Name, updateResto.Name);
            Assert.AreEqual(restaurant.Grade.Score, updateResto.Grade.Score);
            Assert.AreEqual(restaurant.Address.Street, updateResto.Address.Street);

            //Clean up database
            await deleteTestResto();
        }
Beispiel #15
0
        public RestaurantServiceTests()
        {
            var restaurants = new List <Restaurant>
            {
                new Restaurant {
                    AverageRating = 9, Name = "Mike", State = "FL", Street = "123 billy St.", ZipCode = 18172, PhoneNumber = "123412312", Website = "www.hithere.com", City = "Tampa"
                },
                new Restaurant {
                    AverageRating = 9, Name = "Jake", State = "FL", Street = "123 Me St.", ZipCode = 18172, PhoneNumber = "123412312", Website = "www.hithere.com", City = "Tampa"
                },
                new Restaurant {
                    AverageRating = 9, Name = "Abe", State = "FL", Street = "123 Me St.", ZipCode = 18172, PhoneNumber = "123412312", Website = "www.hithere.com", City = "Tampa"
                },
                new Restaurant {
                    AverageRating = 4, Name = "Frank", State = "billy", Street = "123 Me St.", ZipCode = 18172, PhoneNumber = "123412312", Website = "www.hithere.com", City = "Tampa"
                }
            };

            _mockRepository = new Mock <IRestaurantRepository>();
            _mockRepository.Setup(x => x.GetById(It.IsAny <Guid>())).Returns(new Restaurant {
                Reviews = new List <Review>()
            });
            _mockRepository.Setup(x => x.Update(It.IsAny <Restaurant>()));
            _mockRepository.Setup(x => x.Get()).Returns(restaurants);
            _mockRepository.Setup(x => x.Add(It.IsAny <Restaurant>()));
            _mockRepository.Setup(x => x.Delete(It.IsAny <Restaurant>()));

            _restaurantService = new RestaurantService(_mockRepository.Object);
        }
        public MenuPage()
        {
            InitializeComponent();

            var restaurantProfile = RestaurantService.GetRestaurantInfo();

            restaurantProfileImage.Source = restaurantProfile.LogoImage;
            restaurantProfileName.Text    = restaurantProfile.Name;

            var menuList = SidemenuService.GetSidemenuItem();

            ListViewMenu.ItemsSource   = menuList;
            ListViewMenu.ItemSelected += (sender, e) =>
            {
                if (e.SelectedItem == null)
                {
                    return;
                }

                var page       = ((SideMenuItem)e.SelectedItem).Page;
                var parameters = ((SideMenuItem)e.SelectedItem).Params;
                PageService.GetRootPage().SideMenuChangePage(page, parameters);
                ((MasterDetailPage)Application.Current.MainPage).IsPresented = false;
                ListViewMenu.SelectedItem = null;
            };
        }
Beispiel #17
0
        // GET: Restaurant
        private RestaurantService CreateRestaurantService()
        {
            // var userId = Guid.Parse(User.Identity.GetUserId());
            var service = new RestaurantService();

            return(service);
        }
        public async Task Restaurant_Is_Added_When_Correct()
        {
            using (var context = new ApplicationDbContext(options))
            {
                var restaurantRequest = new RestaurantRequest()
                {
                    Name = "Test"
                };

                var manager = new AppUser()
                {
                    UserName = "******"
                };

                mockMapper.Setup(x => x.Map <RestaurantRequest, Restaurant>(It.IsAny <RestaurantRequest>()))
                .Returns(new Restaurant()
                {
                    Name    = restaurantRequest.Name,
                    Manager = manager
                });

                mockUserService.Setup(x => x.FindUserByNameOrEmailAsync(manager.UserName)).Returns(Task.FromResult(manager));

                var restaurantService = new RestaurantService(context, mockUserService.Object, mockMapper.Object, mockBlobStorageService.Object);
                var length            = await context.Restaurants.CountAsync();

                var restaurant = await restaurantService.SaveRestaurantAsync(restaurantRequest, manager.UserName);

                Assert.Equal(length + 1, await context.Restaurants.CountAsync());
                Assert.Equal(restaurant.Name, restaurantRequest.Name);
            }
        }
Beispiel #19
0
 public PZServices()
 {
     _db = new PZRepoContext();
     _restaurantService = new RestaurantService(new RestaurantRepo(_db));
     _reviewService     = new ReviewService(new ReviewRepo(_db));
     //UpdateAverageRating();
 }
Beispiel #20
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="settings">settings</param>
 /// <param name="restaurantService">restaurantService</param>
 /// <param name="staffService">staffService</param>
 /// <param name="customerService">customerService</param>
 public RestaurantManager(Settings settings, RestaurantService restaurantService, StaffService staffService, CustomerService customerService)
 {
     _settings          = settings;
     _restaurantService = restaurantService;
     _staffService      = staffService;
     _customerService   = customerService;
 }
Beispiel #21
0
        public void Can_Get_RestaurantDTO()
        {
            var context = TestingSetup.GetContext();
            IRestaurantRepository repo = new RestaurantRepository(context);

            var restaurant = new Restaurant()
            {
                ExternalId = "31e045af-cc46-4e28-a783-71d456d86400",
                Name       = "New Restaurant"
            };

            context.Restaurants.Add(restaurant);
            context.SaveChanges();

            var svc = new RestaurantService(repo);

            Task task = svc.GetRestaurantByIdAsync("31e045af-cc46-4e28-a783-71d456d86400")
                        .ContinueWith(innerTask =>
            {
                var result = innerTask.Result;
                Assert.IsType <RestaurantDTO>(result);
                Assert.Equal("America/New York", result.TimeZone);
                Assert.Equal("New Restaurant", result.Name);
            });
        }
Beispiel #22
0
        //Set all the ratings and datagridview table
        public void setRating(String name, String location)
        {
            Item item = new Item();
            RestaurantService restaurantService = new RestaurantService();
            Restaurant        restaurant        = new Restaurant();

            restaurant.Name     = name;
            restaurant.Location = location;

            restaurant   = restaurantService.GetAllRate(restaurant);
            label17.Text = name + " (" + location + ")";
            label6.Text  = restaurant.Environment.ToString();
            label8.Text  = restaurant.Behaviour.ToString();
            rid          = restaurant.Rid;

            ItemService itemService = new ItemService();

            item.Rid   = rid;
            foodRating = itemService.GetItemsRating(item);

            label4.Text = foodRating.ToString();

            DataTable table = new DataTable();

            table = itemService.GetTable(item);
            dataGridView1.DataSource = table;

            totalRating = (restaurant.Environment + restaurant.Behaviour + foodRating) / 3;
            label2.Text = totalRating.ToString();
        }
Beispiel #23
0
 public virtual void SetUp()
 {
     webApiClientMock = new Mock <IWebApiClient>();
     // webApiClientMock.Setup(i => i.GetAsync<IEnumerable<Restaurant>>(It.IsAny<string>())).ReturnsAsync(new List<Restaurant>());
     webApiClientMock.Setup(i => i.GetAsync(It.IsAny <Uri>(), It.IsAny <Dictionary <string, string> >())).ReturnsAsync(GetResponse);
     restaurantService = new RestaurantService(webApiClientMock.Object);
 }
        public RestaurantServiceTests()
        {
            _justEatRepositoryMock         = new JustEatRepositoryMock();
            _justEatIntegrationServiceMock = new JustEatApiIntegrationServiceMock();

            _restaurantService = new RestaurantService(_justEatRepositoryMock.Object, _justEatIntegrationServiceMock.Object);
        }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="restaurantService">restaurantService</param>
 /// <param name="productService">productService</param>
 /// <param name="staffService">staffService</param>
 /// <param name="supplyService">supplyService</param>
 public StockManager(RestaurantService restaurantService, ProductService productService, StaffService staffService, SupplyService supplyService)
 {
     _restaurantService = restaurantService;
     _productService    = productService;
     _staffService      = staffService;
     _supplyService     = supplyService;
 }
        public void Throw_WhenUserWithProvidedIdNotFound(string userID)
        {
            // Arrange
            var restaurantRepository = new Mock <IEfRepository <Restaurant> >();
            var userRepository       = new Mock <IEfRepository <User> >();
            var tableRepository      = new Mock <IEfRepository <Table> >();
            var userRoleService      = new Mock <IUserRoleService>();
            var saveContext          = new Mock <ISaveContext>();

            ICollection <User> usersCollection = new List <User>();

            userRepository.Setup(u => u.All).Returns(() =>
            {
                return(usersCollection.AsQueryable());
            });

            IRestaurantService restaurantService = new RestaurantService(
                restaurantRepository.Object,
                userRepository.Object,
                tableRepository.Object,
                userRoleService.Object,
                saveContext.Object);

            // Act & Assert
            Assert.Throws <NullReferenceException>(() => restaurantService.GetRestaurantByManagerID(userID));
        }
        public void Create1Restaurant()
        {
            var resto = new Restaurant();

            resto.name            = "test";
            resto.phoneNumber     = "047633431";
            resto.comment         = "bon";
            resto.email           = "*****@*****.**";
            resto.note            = new Note();
            resto.note.notes      = 5;
            resto.note.lastDate   = "24 Janvier 2005";
            resto.note.comment    = "test";
            resto.address         = new Address();
            resto.address.rue     = "test rue";
            resto.address.ville   = "Grenoble";
            resto.address.zipCode = 38000;

            var beforeCreation = new RestaurantService().getAllRestaurant().Result.Count;

            new RestaurantService().createRestaurant(resto);

            var afterCreation = new RestaurantService().getAllRestaurant().Result.Count;

            Assert.AreEqual(beforeCreation + 1, afterCreation);
        }
Beispiel #28
0
        public async Task <IActionResult> Best()
        {
            var restoListQwery  = new RestaurantService().BestResto();
            var bestRestaurants = await restoListQwery;

            return(View(bestRestaurants));
        }
        public IHttpActionResult GetAll()
        {
            RestaurantService restaurantService = CreateRestaurantService();
            var restaurants = restaurantService.GetRestaurants();

            return(Ok(restaurants));
        }
Beispiel #30
0
        //Rate Behaviour
        public void rateBehaviour()
        {
            String Behaviour = bRate.Text.ToString();

            if (numberVerify(bRate))
            {
                Restaurant restaurant = new Restaurant();
                restaurant.Name      = name;
                restaurant.Location  = location;
                restaurant.Rid       = rid;
                restaurant.Behaviour = int.Parse(Behaviour);

                RestaurantService restaurantService = new RestaurantService();

                if (restaurantService.RateBehaviour(restaurant) == 1)
                {
                    MessageBox.Show("Behaviour Rated Successfully!");
                    setRating(name, location);
                }
                else
                {
                    MessageBox.Show("Couldn't Rate Behaviour!");
                }
            }
        }
Beispiel #31
0
        public void Return_AllRestaurantsWhenMethodIsInvoced()
        {
            // Arrange
            var restaurantRepository = new Mock <IEfRepository <Restaurant> >();
            var userRepository       = new Mock <IEfRepository <User> >();
            var tableRepository      = new Mock <IEfRepository <Table> >();
            var userRoleService      = new Mock <IUserRoleService>();
            var saveContext          = new Mock <ISaveContext>();

            IEnumerable <Restaurant> expectedResultCollection = new List <Restaurant>();

            restaurantRepository.Setup(r => r.All).Returns(() =>
            {
                return(expectedResultCollection.AsQueryable());
            });

            IRestaurantService restaurantService = new RestaurantService(
                restaurantRepository.Object,
                userRepository.Object,
                tableRepository.Object,
                userRoleService.Object,
                saveContext.Object);

            // Act
            IEnumerable <Restaurant> restaurantsResult = restaurantService.GetAll();

            // Assert
            Assert.That(restaurantsResult, Is.EqualTo(expectedResultCollection));
        }
 public void GetRestaurantsShouldGetEmptyListIfOutcodeIsEmptyString()
 {
     const string outcode = "";
     HttpClient httpClient = new HttpClient();
     RestaurantService service = new RestaurantService(httpClient);
     IList<Restaurant> restaurants = service.GetRestaurants(outcode);
     Assert.AreEqual(0, restaurants.Count);
 }
        public int RestaurantAdd(int cityid, string name)
        {
            RestaurantService r = new RestaurantService();

            Restaurant model = new Restaurant();

            model.CityID = cityid;
            model.Name = name;

            return r.Add(model, 0);
        }
        /// <summary>
        /// Method to Add the order to CustomerOrder Table
        /// </summary>
        /// <param name="order">customer order data</param>
        /// <param name="addOrder">addorder data</param>
        private void AddOrderToCustomer(CustomerOrder order, RestaurantService.Contracts.AddOrder addOrder)
        {
            order.Items = new List<ItemOrderXRef>();

            addOrder.Items.ForEach(y =>
            {
                var itemId = (from x in context.foodItems
                              where x.DishName == y.DishName
                              select x.FoodItemId).FirstOrDefault();
                order.Items.Add(new ItemOrderXRef() { FoodItemId = itemId, ItemQty = y.ItemQty, CustomerOrderId = order.CustomerOrderId });
            });
        }
        /// <summary>
        /// Method to Place an Order
        /// </summary>
        /// <param name="addOrder">add order data</param>
        public void PlaceOrder(RestaurantService.Contracts.AddOrder addOrder)
        {
            CustomerOrder custOrder = new CustomerOrder();
            custOrder.TableNumber = addOrder.TableNumber;
            custOrder.StartTime = DateTime.Now;
            custOrder.CompletionTime = (DateTime)SqlDateTime.MinValue;

            var orderCreated = context.customerOrders.Add(custOrder);

            this.AddOrderToCustomer(orderCreated, addOrder);

            this.context.SaveChanges();
        }
 //
 // GET: /Restaurants/
 public ActionResult Index()
 {
     try
     {
         List<Restaurant> r = new RestaurantService().ReadAll();
         if (r == null || r.Count == 0)
             return HttpNotFound("Il n'y a pas de restaurants correspondant à vos critères.");
         return View(r);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
 public ActionResult Selection(int? id)
 {
     try
     {
         if (!id.HasValue || id <= 0)
             return RedirectToAction("Index");
         Restaurant r = new RestaurantService().ReadOne(id.Value);
         if (r == null)
             return HttpNotFound("Restaurant inconnu.");
         return View(r);
     }
     catch(Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
 private RestaurantService CreateRestaurantService(string outcode, HttpResponseMessage response)
 {
     Mock<FakeHttpMessageHandler> msgHandler = CreateFakeHttpMessageHandlerMock(outcode, response);
     HttpClient fakeHttpClient = new HttpClient(msgHandler.Object);
     RestaurantService service = new RestaurantService(fakeHttpClient);
     return service;
 }
        public List<Restaurant> RestaurantsGetByCity(int cityid)
        {
            RestaurantService r = new RestaurantService();

            return r.GetByCityId(cityid).ToList();
        }