Пример #1
0
        public void CountryManagerTest()
        {
            CityManager      cityManager      = new CityManager(new UnitOfWork(new DataContext()));
            CountryManager   countryManager   = new CountryManager(new UnitOfWork(new DataContext()));
            ContinentManager continentManager = new ContinentManager(new UnitOfWork(new DataContext()));

            //Verwijder alles in tabels
            cityManager.RemoveAll();
            countryManager.RemoveAllCountries();
            continentManager.RemoveAll();

            //Aanmaak Continent
            continentManager.Add(new Continent("TestContinent"));
            List <Continent> continents = continentManager.GetAllContinents();
            Continent        continent  = continents[0];

            Assert.AreEqual(1, continents.Count);

            //Toevoegen van Country
            countryManager.Add(new Country("TestCountry", continent, 100, 10));

            List <Country> countries = countryManager.GetAllCountries();
            Country        country   = countries[0];

            Assert.AreEqual(1, countries.Count);
            Assert.AreEqual("TestCountry", country.Name);

            //Verwijder alles in tabels
            cityManager.RemoveAll();
            countryManager.RemoveAllCountries();
            continentManager.RemoveAll();
        }
Пример #2
0
        public void ContinentManagerTest()
        {
            CityManager      cityManager      = new CityManager(new UnitOfWork(new DataContext()));
            CountryManager   countryManager   = new CountryManager(new UnitOfWork(new DataContext()));
            ContinentManager continentManager = new ContinentManager(new UnitOfWork(new DataContext()));

            //Verwijder alles in tabels
            cityManager.RemoveAll();
            countryManager.RemoveAllCountries();
            continentManager.RemoveAll();

            //Aanmaak Continent
            continentManager.Add(new Continent("TestContinent"));
            List <Continent> continents = continentManager.GetAllContinents();
            Continent        continent  = continents[0];

            Assert.AreEqual(1, continents.Count);

            Assert.AreEqual("TestContinent", continent.Name);

            continent.SetName("TestContAangepast");
            continent.SetPopulation(100);

            continentManager.UpdateContinent(continent);

            Assert.AreEqual("TestContAangepast", continent.Name);
            Assert.AreEqual(100, continent.Population);

            continentManager.RemoveContinent(continent.ID);
            continents = continentManager.GetAllContinents();

            Assert.AreEqual(0, continents.Count);

            //Verwijder alles in tabels
            cityManager.RemoveAll();
            countryManager.RemoveAllCountries();
            continentManager.RemoveAll();
        }
Пример #3
0
 public ActionResult <List <SampleContinent> > GetAllContinents()
 {
     try
     {
         return(ContinentManager.GetAllContinents().Select(x => new SampleContinent
         {
             ID = $"http://localhost:3000/api/Continent/{x.ID}",
             Name = x.Name,
             Population = x.Population,
             Countries = CountryManager.GetContinentWithName(x).Select(y => $"http://localhost:3000/api/Continent/{x.ID}/Country/" + y.ID.ToString()).ToList()
         }).ToList());
     }
     catch
     {
         Response.StatusCode = 400;
         return(null);
     }
 }