public void AuthorizedUserCannotAddVenueIfHeIsNotAdminnistrator()
 {
     var user = new User("user12", "user12", Roles.User);
     var data = new HotelBookingSystemData();
     var controller = new VenuesController(data, user);
     var view = controller.Add("venue one", "address one", "description one");
 }
 public void AuthorizedUserCannotAddRoomIfHeIsNotAdminnistrator()
 {
     var user = new User("user12", "user12", Roles.User);
     var data = new HotelBookingSystemData();
     var controller = new RoomsController(data, user);
     var view = controller.Add(1, 2, 30.00m);
 }
        public void UnAuthorizedUserCannotLogout()
        {
            var data = new HotelBookingSystemData();
            var controller = new UsersController(data, null);

            var view = controller.Logout();
        }
 public void AuthorizedUserCannotAddPeriodIfHeIsNotAdminnistrator()
 {
     var user = new User("user12", "user12", Roles.User);
     var data = new HotelBookingSystemData();
     var controller = new RoomsController(data, user);
     var view = controller.AddPeriod(1, DateTime.Now, DateTime.Now);
 }
        public void GetIncorrectRoomFromRepositoryMustReturnNull()
        {
            var data = new HotelBookingSystemData();
            var expected = new Room(2, 30.00m);
            data.RepositoryWithRooms.Add(expected);
            var actual = data.RepositoryWithRooms.Get(2);

            Assert.AreEqual(null, actual);
        }
        public void GetIncorrectVenueFromRepositoryMustReturnNull()
        {
            var user = new User("admin1", "admin1", Roles.VenueAdmin);
            var data = new HotelBookingSystemData();
            var expected = new Venue("one", "address one", "vanue with address one", user);
            data.RepositoryWithVenues.Add(expected);
            var actual = data.RepositoryWithVenues.Get(2);

            Assert.AreEqual(null, actual);
        }
        public void AuthorizedUserMustLogoutSuccessfully()
        {
            var user = new User("admin1", "admin1", Roles.VenueAdmin);
            var data = new HotelBookingSystemData();
            var controller = new UsersController(data, user);

            var view = controller.Logout();

            var expected = "The user admin1 has logged out.";
            Assert.AreEqual(expected, view.Display());
        }
        public void GetAllVanuesWithoutDataMustReturnNoVanues()
        {
            var user = new User("admin1", "admin1", Roles.VenueAdmin);
            var data = new HotelBookingSystemData();
            var controller = new VenuesController(data, user);
            var vanues = controller.All();

            var expected = "There are currently no venues to show.";

            Assert.AreEqual(expected, vanues.Display());
        }
        public void GetAllVanuesWithDataMustReturnThem()
        {
            var user = new User("admin1", "admin1", Roles.VenueAdmin);
            var data = new HotelBookingSystemData();
            var venue = new Venue("one", "address one", "vanue with address one", user);
            data.RepositoryWithVenues.Add(venue);

            var controller = new VenuesController(data, user);
            var vanues = controller.All();

            var expected = new StringBuilder();
            expected.AppendFormat("*[{0}] {1}, located at {2}", venue.Id, venue.Name, venue.Address)
                    .AppendLine()
                    .AppendFormat("Free rooms: {0}", venue.Rooms.Count);

            Assert.AreEqual(expected.ToString(), vanues.Display());
        }
        public void StartOperation()
        {
            var database = new HotelBookingSystemData();
            User currentUser = null;
            while (true)
            {
                string url = Console.ReadLine();
                if (url == null)
                {
                    break;
                }

                var executionEndpoint = new Endpoint(url);

                var controllerType =
                    Assembly.GetExecutingAssembly()
                            .GetTypes()
                            .FirstOrDefault(type => type.Name == executionEndpoint.ControllerName);
                var controller = Activator.CreateInstance(controllerType, database, currentUser) as Controller;
                var action = controllerType.GetMethod(executionEndpoint.ActionName);
                object[] parameters = MapParameters(executionEndpoint, action);
                string viewResult = string.Empty;
                try
                {
                    var view = action.Invoke(controller, parameters) as IView;
                    viewResult = view.Display();
                    currentUser = controller.CurrentUser;
                }
                catch (Exception ex)
                {
                    viewResult = new Error(ex.InnerException.Message).Display();
                }

                Console.WriteLine(viewResult);
            }
        }
 public void UnAuthorizedUserCannotBook()
 {
     var data = new HotelBookingSystemData();
     var controller = new RoomsController(data, null);
     var view = controller.Book(1, DateTime.Now, DateTime.Now, "comment one");
 }
 public void UnAuthorizedUserCannotViewVanuesDetails()
 {
     var data = new HotelBookingSystemData();
     var controller = new VenuesController(data, null);
     var view = controller.Details(1);
 }
 public void UnAuthorizedUserCannotAddVenue()
 {
     var data = new HotelBookingSystemData();
     var controller = new VenuesController(data, null);
     var view = controller.Add("venue one", "address one", "description one");
 }
 public void UnAuthorizedUserCannotAddRoom()
 {
     var data = new HotelBookingSystemData();
     var controller = new RoomsController(data, null);
     var view = controller.Add(1, 2, 30.00m);
 }
 public void UnAuthorizedUserCannotAddPeriod()
 {
     var data = new HotelBookingSystemData();
     var controller = new RoomsController(data, null);
     var view = controller.AddPeriod(1, DateTime.Now, DateTime.Now);
 }
 public void UnAuthorizedUserCannotViewTheirProfile()
 {
     var data = new HotelBookingSystemData();
     var controller = new UsersController(data, null);
     var view = controller.MyProfile();
 }
 public void UnAuthorizedUserCannotViewBookings()
 {
     var data = new HotelBookingSystemData();
     var controller = new RoomsController(data, null);
     var view = controller.ViewBookings(1);
 }