Example #1
0
        public void CountryAddCapitalAlreadyAddedThrowsException()
        {
            Continent continent = new Continent("Azië");
            Country   country   = new Country("vietnam", 95540000, 331.212f, continent);
            City      capital   = new City("Hanoi", 7520700, country);

            country.AddCaptial(capital);
            Action act = () => country.AddCaptial(capital);

            act.Should().Throw <ArgumentException>().WithMessage("capital: Hanoi already added.");
        }
Example #2
0
        public static Country FromDCountryToCountry(DCountry dCountry)
        {
            Country country = new Country(dCountry.Name, dCountry.Population, dCountry.Surface, FromDContinentToContinent(dCountry.Continent))
            {
                Id = (uint)dCountry.Id
            };

            // Todo: Check if city isnt in capital catch?
            if (dCountry.Capitals != null)
            {
                foreach (DCity dCity in dCountry.Capitals)
                {
                    City toAdd = new City(dCity.Name, dCity.Population, country)
                    {
                        Id = (uint)dCity.Id, CapitalFrom = country
                    };
                    country.AddCaptial(toAdd);
                }
            }
            if (dCountry.Cities != null)
            {
                foreach (DCity dCity in dCountry.Cities)
                {
                    City toAdd = new City(dCity.Name, dCity.Population, country)
                    {
                        Id = (uint)dCity.Id
                    };
                    country.AddCity(toAdd);
                }
            }
            return(country);
        }
Example #3
0
        public void CountryAddCapitalNormalTest()
        {
            Continent continent = new Continent("Azië");
            Country   country   = new Country("vietnam", 95540000, 331.212f, continent);
            City      capital   = new City("Hanoi", 7520700, country);
            Action    act       = () => country.AddCaptial(capital);

            act.Should().NotThrow();
            country.Capitals.Count.Should().Be(1);
        }
Example #4
0
        public void CountryRemoveCityThatIsCapitalThrowsException()
        {
            Continent continent = new Continent("Azië");
            Country   country   = new Country("vietnam", 95540000, 331.212f, continent);
            City      capital   = new City("Hanoi", 7520700, country);

            country.AddCaptial(capital);
            Action act = () => country.RemoveCity(capital);

            act.Should().Throw <ArgumentException>().WithMessage("city: Hanoi is in capitals. pls remove from capital first.");
        }
Example #5
0
        public void CountryRemoveCapitalNullThrowsException()
        {
            Continent continent = new Continent("Azië");
            Country   country   = new Country("vietnam", 95540000, 331.212f, continent);
            City      capital   = new City("Hanoi", 7520700, country);

            country.AddCaptial(capital);
            Action act = () => country.RemoveCapital(null);

            act.Should().Throw <ArgumentException>().WithMessage("city can't be null");
        }