public void TestForAdministratorsController()
        {
            tc.PrepareDBForTests();
            User          user  = new User(FlyingCenterConfig.ADMIN_NAME, FlyingCenterConfig.ADMIN_PASSWORD, UserType.Administrator);
            string        token = GetTokenAsync(user);
            Administrator admin = tc.CreateRandomAdministrator();

            CreateAdmin(token, CreateAdminUrl, admin);
            Administrator myAdmin = GetAdminByUserName(token, GetAdminUrl + admin.User_Name);

            Assert.AreEqual(myAdmin.User_Name, admin.User_Name);
        }
Beispiel #2
0
        public void CancelTicketSuccessfuly()
        {
            tc.PrepareDBForTests();
            Flight flight = new Flight {
                AirLineCompany_Id = tc.airlineToken.User.Id, Departure_Time = new DateTime(2020, 12, 10, 00, 00, 00), Landing_Time = new DateTime(2020, 12, 11), Origin_Country_Code = tc.adminFacade.GetCountryByName("Israel").Id, Destination_Country_Code = tc.adminFacade.GetCountryByName("Israel").Id, Remaining_Tickets = 100
            };

            flight.Id = tc.airlineFacade.CreateFlight(tc.airlineToken, flight);
            tc.customerFacade.PurchaseTicket(tc.customerToken, flight);
            Assert.AreEqual(tc.customerFacade.GetAllMyFlights(tc.customerToken).Count, 1);
            tc.customerFacade.CancelTicket(tc.customerToken, tc.customerFacade.GetAllMyTickets(tc.customerToken)[0]);
            Assert.AreEqual(tc.customerFacade.GetAllMyFlights(tc.customerToken).Count, 0);
        }
Beispiel #3
0
        public void GetAllArlineCompanies()
        {
            tc.PrepareDBForTests();
            AirlineCompany airline = new AirlineCompany("AirlineForUpdate", "Airline " + tc.UserTest(), "123", (int)tc.adminFacade.GetCountryByName("Israel").Id);

            airline.Id = tc.adminFacade.CreateNewAirline(tc.adminToken, airline);
            IList <AirlineCompany> AirlineCompanies = new AnonymousUserFacade().GetAllAirlineCompanies();

            Assert.AreEqual(AirlineCompanies.Count, 2);
        }
        public void GetAllTicketsForCurrentAirline()
        {
            tc.PrepareDBForTests();
            Flight flight = new Flight {
                AirlineCompany_Id = tc.airlineToken.User.Id, Departure_Time = DateTime.Now, Landing_Time = DateTime.Now + TimeSpan.FromHours(1), Origin_Country_Code = tc.adminFacade.GetCountryByName("Israel").Id, Destination_Country_Code = tc.adminFacade.GetCountryByName("Israel").Id, Remaining_Tickets = 100
            };

            flight.Id = tc.airlineFacade.CreateFlight(tc.airlineToken, flight);
            tc.customerFacade.PurchaseTicket(tc.customerToken, flight);
            IList <Ticket> tickets = tc.airlineFacade.GetAllTicketsByAirline(tc.airlineToken);

            Assert.AreEqual(1, tickets.Count);
        }
        public void WrongPasswordWhenTryLoginAsAdmin()
        {
            tc.PrepareDBForTests();
            Administrator admin = new Administrator("Admin" + tc.UserTest(), "9999");

            admin.Admin_Number = tc.adminFacade.CreateNewAdmin(tc.adminToken, admin);
            FlyingCenterSystem.GetUserAndFacade(admin.User_Name, "ErrorPassword", out ILogin token, out FacadeBase facade);
        }
Beispiel #6
0
        public void RemoveAdministratorSuccessfully()
        {
            tc.PrepareDBForTests();
            Administrator admin = tc.CreateRandomAdministrator();

            admin.Admin_Number = tc.adminFacade.CreateNewAdmin(tc.adminToken, admin);
            tc.adminFacade.RemoveAdministrator(tc.adminToken, admin);
            Assert.AreEqual(tc.adminFacade.GetAdminByUserName(tc.adminToken, admin.User_Name).Id, 0);
        }
        public void GetAirlineCompanyByUserName()
        {
            tc.PrepareDBForTests();
            AirlineCompany airline = new AnonymousUserFacade().GetAirlineByUserName(tc.airlineToken.User.User_Name);

            Assert.AreNotEqual(airline, null);
        }
        public void RemoveAdministratorSuccessfully()
        {
            tc.PrepareDBForTests();
            Administrator admin = new Administrator("Admin: " + tc.UserTest(), "123");

            admin.Admin_Number = tc.adminFacade.CreateNewAdmin(tc.adminToken, admin);
            tc.adminFacade.RemoveAdministrator(tc.adminToken, admin);
            Assert.AreEqual(tc.adminFacade.GetAdminByUserName(tc.adminToken, admin.User_Name), null);
        }