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 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 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 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 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 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());
        }
Example #7
0
        // BUG: set client
        public Booking(User client, DateTime startBookDate, DateTime endBookDate, decimal totalPrice, string comments)
        {
            if (this.EndBookDate < this.StartBookDate)
            {
                throw new ArgumentException("The date range is invalid.");
            }

            this.Client = client;
            this.StartBookDate = startBookDate;
            this.EndBookDate = endBookDate;
            this.TotalPrice = totalPrice;
            this.Comments = comments;
        }
        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 IView Register(string username, string password, string confirmPassword, string role)
        {
            if (password != confirmPassword)
            {
                throw new ArgumentException("The provided passwords do not match.");
            }

            this.EnsureNoLoggedInUser();

            var existingUser = this.Data.RepositoryWithUsers.GetByUsername(username);
            if (existingUser != null)
            {
                throw new ArgumentException(string.Format("A user with username {0} already exists.", username));
            }

            Roles userRole = (Roles)Enum.Parse(typeof(Roles), role, true);
            var user = new User(username, password, userRole);
            this.Data.RepositoryWithUsers.Add(user);
            return this.View(user);
        }
 public RoomsController(IHotelBookingSystemData data, User user)
     : base(data, user)
 {
 }
 // BUG: change internal to public
 public Controller(IHotelBookingSystemData data, User user)
 {
     this.Data = data;
     this.CurrentUser = user;
 }
 public AuthorizationFailedException(string message, User user)
     : base(message)
 {
     this.User = user;
 }
 public Logout(User user)
     : base(user)
 {
 }
 public MyProfile(User user)
     : base(user)
 {
 }
 public Login(User user)
     : base(user)
 {
 }
 public Register(User user)
     : base(user)
 {
 }