public void Setup()
 {
     _restaurantService = new RestaurantService();
     _adressService     = new AdressService();
     _mainRestaurant    = new Restaurant("le rating", "0788888888", "bonjour je suis le test de restaurant", "*****@*****.**", null);
     _restaurantService.AddRestaurant(_mainRestaurant);
 }
        public void CreateRestaurantTest()
        {
            Adress     a = new Adress(12, "rue de la chevre", 38500, "voiron");
            Restaurant r = new Restaurant("le chevre", "0788888888", "bonjour je suis la description", "*****@*****.**", a);

            _restaurantService.AddRestaurant(r);
            var restId = r.ID; //this is put after because the GUID seams to be only created when the object is inserted into the database

            var restaurant = _restaurantService.GetAllRestaurant().Find(m => m.ID == restId);

            Assert.IsTrue(restaurant.Name == r.Name);
            Assert.IsTrue(restaurant.Phone == r.Phone);
            Assert.IsTrue(restaurant.Description == r.Description);
            Assert.IsTrue(restaurant.Email == r.Email);

            _restaurantService.DeleteRestaurant(restaurant); //deletes it to clean the database
        }
        //Restaurant add button - recieves texts from RestaurantName, RestaurantLocation, EnvironmentRate, BehaviourRate and add to restaurant table
        private void button1_Click(object sender, EventArgs e)
        {
            String name              = RestaurantName.Text.ToString();
            String location          = RestaurantLocation.Text.ToString();
            String stringEnvironment = EnvironmentRate.Text.ToString();
            String stringBehaviour   = BehaviourRate.Text.ToString();
            int    environment       = 0;
            int    behaviour         = 0;
            int    eflag             = 0;
            int    bflag             = 0;

            if (fieldCheckForRestaurant(name, location, stringEnvironment, stringBehaviour))
            {
                if (RateVerify(EnvironmentRate))
                {
                    environment = int.Parse(stringEnvironment);
                    eflag       = 1;
                }
                if (RateVerify(BehaviourRate))
                {
                    behaviour = int.Parse(stringBehaviour);
                    bflag     = 1;
                }

                if (eflag == 1 && bflag == 1)
                {
                    Restaurant restaurant = new Restaurant();
                    restaurant.Name        = name;
                    restaurant.Environment = environment;
                    restaurant.Location    = location;
                    restaurant.Behaviour   = behaviour;

                    RestaurantService restaurantService = new RestaurantService();
                    if (restaurantService.GetByLocation(restaurant) == "non-exist")
                    {
                        int RID = restaurantService.GetRID();
                        restaurant.Rid = RID + 1;
                        if (restaurantService.AddRestaurant(restaurant) == 1)
                        {
                            MessageBox.Show("Restaurant Added Successfully!");
                            LoadRestaurant();
                        }
                        else
                        {
                            MessageBox.Show("Couldn't Add Restaurant!");
                        }
                    }
                    else if (restaurantService.GetByLocation(restaurant) == "exist")
                    {
                        MessageBox.Show("Restaurant Already Exist");
                    }
                }
            }
            else
            {
                MessageBox.Show("Please check all field is filled or not");
            }
        }
        public void Setup()
        {
            _restaurantService = new RestaurantService();
            _ratingService     = new RatingService();
            Adress a = new Adress(12, "rue de la rating", 38500, "voiron");

            _mainRestaurant = new Restaurant("le rating", "0788888888", "bonjour je suis la rating", "*****@*****.**", a);
            _restaurantService.AddRestaurant(_mainRestaurant);
        }
Exemple #5
0
        public void TestRestAdd()
        {
            var            restRepo   = new Mock <IRestaurantRepository>();
            var            reviewRepo = new Mock <IReviewerRepository>();
            var            service    = new RestaurantService(restRepo.Object, reviewRepo.Object);
            RestaurantInfo dummyRest  = new RestaurantInfo(34, "repoTest", "test city", "test street", "descrip", "testemail");

            restRepo.Setup(i => i.AddRestaurant(new RestaurantInfo(34, "repoTest", "test city", "test street", "descrip", "testemail"))).Returns(true);
            var expected = true;
            var actual   = service.AddRestaurant(dummyRest);

            Assert.AreEqual(expected, actual, "Delete failed");
        }
Exemple #6
0
        public void Add_PassedARestaurant_CallsAdd()
        {
            var service = new RestaurantService(_moqRepo.Object);
            var r       = new Restaurant
            {
                RestaurantId = 5,
                Name         = "TestRestaurant5",
                City         = "city5",
                Zipcode      = "10804",
                State        = "NY",
                Street       = " 5 a",
                AvgRating    = 9.9
            };

            service.AddRestaurant(r);
            _moqRepo.Verify(m => m.Add(It.IsAny <Restaurant>()), Times.Once);
        }
        public SaveResponse AddRestaurant([FromBody] CreateRestaurantModel restaurant)
        {
            if (!ValidateRestaurant(restaurant))
            {
                _logger.LogWarning("Invalid restaurant model");
                return(new SaveResponse {
                    ErrorMessage = "Unable to add Restaurant: Invalid model."
                });
            }

            /*if (!User.IsInRole("AddRestaurant"))
             * {
             *  _logger.LogWarning("Unauthorized access attempt");
             *  return new SaveResponse { ErrorMessage = "You are not authorized to add restautants" };
             * }*/

            var service = new RestaurantService(new RestaurantDataAccess());

            // assumption: (not shown) all write operations would normally receive user information from the controller
            return(service.AddRestaurant(restaurant));
        }
Exemple #8
0
 public void AddRestaurant(Restaurant restaurant)
 {
     _restaurantService.AddRestaurant(restaurant);
 }
 [Authorize] // Forces Login To Post
 public void Post([FromBody] Restaurant restaurant)
 {
     _service.AddRestaurant(restaurant, User.Identity.Name);
 }