コード例 #1
0
 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);
 }
コード例 #2
0
        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");
        }
コード例 #3
0
        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");
        }
コード例 #4
0
        public void TestAuthorize_NoLoggedUser_ShouldThrow()
        {
            var db = new HotelBookingSystemData();
            var controller = new VenuesController(db, null);

            controller.Details(1);
        }
コード例 #5
0
 static void Main()
 {
     System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
     var data = new HotelBookingSystemData();
     var reader = new ConsoleReader();
     var writer = new ConsoleWriter();
     var engine = new Engine(data, reader, writer);
     engine.Run();
 }
コード例 #6
0
        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);
        }
コード例 #7
0
        public static void Main()
        {
            System.Threading.Thread.CurrentThread.CurrentCulture =
                System.Globalization.CultureInfo.InvariantCulture;

            var database = new HotelBookingSystemData();
            var reader = new ConsoleInputReader();
            var writer = new ConsoleOutputWriter();

            var engine = new Engine(database, reader, writer);
            engine.StartOperation();
        }
コード例 #8
0
        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);
        }
コード例 #9
0
        public void TestLogout_WithoutLoggedUser_ShouldThrow()
        {
            var db = new HotelBookingSystemData();
            var controller = new UsersController(db, null);

            controller.Logout();
        }
コード例 #10
0
        public void TestLogout_WithLoggedUser_CurrentUserIsNull()
        {
            var db = new HotelBookingSystemData();
            var controller = new UsersController(db, null);

            controller.Logout();
            var user = controller.CurrentUser;
            Assert.IsNull(user);
        }