public void TestInit()
 {
    data = new HotelBookingSystemData();
    admin = new User("administrator", "Password123", Roles.VenueAdmin);
    user = new User("newUser", "Password123", Roles.User);
    venuesController = new VenuesController(data, admin);
 }
        public void TestAuthorize_ValidUser_ShouldPass()
        {
            var db = new HotelBookingSystemData();
            var controller = new VenuesController(db, new User("Pesho", "1234567", Roles.VenueAdmin));

            controller.Add("Test123", "Sofiq city", "no description");
        }
        public void TestAuthorize_NoSufficientRights_ShouldThrow()
        {
            var db = new HotelBookingSystemData();
            var controller = new VenuesController(db, new User("Pesho", "123456", Roles.User));

            controller.Add("Test", "Sofiq", "no description");
        }
        public void TestAuthorize_NoLoggedUser_ShouldThrow()
        {
            var db = new HotelBookingSystemData();
            var controller = new VenuesController(db, null);

            controller.Details(1);
        }
        public void TestAllVenues_WithoutVenues_CorrectReturnString()
        {
            const string expected = "There are currently no venues to show.";

            var db = new HotelBookingSystemData();
            var controller = new VenuesController(db, null);
            var result = controller.All().Display();

            Assert.AreEqual(expected, result);
        }
        public void TestAllVenues_WithVenues_CorrectReturnString()
        {
            var resultString = new StringBuilder();
            resultString.AppendLine("*[1] New venue, located at Sofia");
            resultString.AppendLine("Free rooms: 0");
            resultString.AppendLine("*[2] New venue 2, located at Sofia");
            resultString.Append("Free rooms: 0");

            var db = new HotelBookingSystemData();
            var user = new User("Pesho", "1234567", Roles.VenueAdmin);
            var controller = new VenuesController(db, user);

            controller.Add("New venue", "Sofia", "");
            controller.Add("New venue 2", "Sofia", "");

            var result = controller.All().Display();

            Assert.AreEqual(resultString.ToString(), result);
        }
 public void Authorize_VenuesDetailsNonAuthorizedUser_ShouldThrow()
 {
     data.VenuesRepository.Add(new Venue("hotel", "Borovo 456", null, null));
     var controller = new VenuesController(data, user);
     controller.Add("hotel Mirage", "Borovo 456", null);
 }
 public void Authorize_VenuesDetailsNonExistingUser_ShouldThrow()
 {
     data.VenuesRepository.Add(new Venue("hotel", "Borovo 456", null, null));
     var controller = new VenuesController(data, null);
     controller.Details(1);
 }