public void AdminControllerCreateNewAirlineAPI()
        {
            ILoggedInAdministratorFacade adminFacade = (ILoggedInAdministratorFacade)TestConfig.fcs.Login(AirlineProjectConfig.TEST_ADMIN_USERNAME, AirlineProjectConfig.TEST_ADMIN_PASSWORD, out ILoginToken adminToken);

            //adminFacade.CreateNewAirline((LoginToken<Administrator>)adminToken, TestData.airline1);  -------- what i want to do

            HttpClient client = new HttpClient();

            client.BaseAddress = new Uri(AdminURL);

            // Add an Accept header for JSON format.
            client.DefaultRequestHeaders.Accept.Add(
                new MediaTypeWithQualityHeaderValue("application/json"));

            string adminCreds = string.Format($"{AirlineProjectConfig.TEST_ADMIN_USERNAME}:{AirlineProjectConfig.TEST_ADMIN_PASSWORD}");

            client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(Encoding.Default.GetBytes(adminCreds)));

            HttpResponseMessage response = client.PostAsync("", new StringContent(JsonConvert.SerializeObject(TestData.airline1), Encoding.Default, "application/json")).Result;

            // -----------------------------------------------------------------------------

            IAnonymousUserFacade   anonymousFacade  = (IAnonymousUserFacade)TestConfig.fcs.Login("testAnonymous", "99999", out ILoginToken anonymousToken);
            IList <AirlineCompany> airlineCompanies = anonymousFacade.GetAllAirlineCompanies();

            Assert.AreEqual(TestData.airline1.AirlineName, airlineCompanies[0].AirlineName);
            Assert.AreEqual(TestData.airline1.CountryCode, airlineCompanies[0].CountryCode);
            Assert.AreEqual(TestData.airline1.Password, airlineCompanies[0].Password);
            Assert.AreEqual(TestData.airline1.UserName, airlineCompanies[0].UserName);
        }
Beispiel #2
0
        public IHttpActionResult GetAllAirlinesCompanies()
        {
            FlyingCenter = FlyingCenterSystem.GetInstance();
            IAnonymousUserFacade   anonymousUserFacade = FlyingCenter.GetFacede(null) as IAnonymousUserFacade;
            IList <AirlineCompany> airlineCompanies    = anonymousUserFacade.GetAllAirlineCompanies();

            if (airlineCompanies.Count == 0)
            {
                return(NotFound());
            }
            return(Ok(airlineCompanies));
        }
Beispiel #3
0
        public void AnonymousFacadeGetAllAirlineCompaniesMethod()
        {
            ILoggedInAdministratorFacade adminFacade = (ILoggedInAdministratorFacade)TestConfig.fcs.Login(AirlineProjectConfig.ADMIN_USERNAME, AirlineProjectConfig.ADMIN_PASSWORD, out ILoginToken adminToken);

            adminFacade.CreateNewAirline((LoginToken <Administrator>)adminToken, TestData.airline1);
            adminFacade.CreateNewAirline((LoginToken <Administrator>)adminToken, TestData.airline2);

            IAnonymousUserFacade   anonymousFacade  = (IAnonymousUserFacade)TestConfig.fcs.Login("testAnonymous", "99999", out ILoginToken anonymousToken);
            IList <AirlineCompany> airlineCompanies = anonymousFacade.GetAllAirlineCompanies();

            Assert.AreEqual(TestData.airline1, airlineCompanies[0]);
            Assert.AreEqual(TestData.airline2, airlineCompanies[1]);
        }
Beispiel #4
0
        public async Task <ActionResult <List <AirlineReducedDTO> > > GetAllAirlineCompanies()
        {
            IList <AirlineCompany> airlines = await Task.Run(() => m_facade.GetAllAirlineCompanies());

            List <AirlineReducedDTO> airlineDTOs = new List <AirlineReducedDTO>();

            foreach (AirlineCompany airline in airlines)
            {
                AirlineReducedDTO airlineDTO = m_mapper.Map <AirlineReducedDTO>(airline);
                airlineDTOs.Add(airlineDTO);
            }
            return(Ok(JsonConvert.SerializeObject(airlineDTOs)));
        }
Beispiel #5
0
        public ActionResult <IList <AirlineCompanyDetailsDTO> > GetAllAirlineCompanies()
        {
            IList <AirlineCompany> airlineCompanies = _anonymousUserFacade.GetAllAirlineCompanies();

            if (airlineCompanies.Count == 0)
            {
                return(NoContent());
            }

            List <AirlineCompanyDetailsDTO> airlineCompanyDetailsDTOs = new List <AirlineCompanyDetailsDTO>();

            foreach (var airlineCompany in airlineCompanies)
            {
                airlineCompanyDetailsDTOs.Add(_mapper.Map <AirlineCompanyDetailsDTO>(airlineCompany));
            }

            return(Ok(airlineCompanyDetailsDTOs));
        }