예제 #1
0
        public void CountryAddCityAlreadyAddedThrowsException()
        {
            Continent continent = new Continent("Azië");
            Country   country   = new Country("vietnam", 95540000, 331.212f, continent);
            City      city      = new City("Hanoi", 7520700, country);

            country.AddCity(city);
            Action act = () => country.AddCity(city);

            act.Should().Throw <ArgumentException>().WithMessage("Hanoi already added.");
        }
예제 #2
0
        static void Main(string[] args)
        {
            var result = PrintWorkDays();

            Country aze = new Country();

            aze.Name       = "Azerbaijan";
            aze.Population = 0;
            aze.UniqueId   = 1;

            City baku = new City();

            baku.Name       = "Baku";
            baku.Population = 4000000;
            baku.UniqueId   = 2;

            //aze.ListCities();

            aze.AddCity(baku);

            aze.ListCities();

            aze.DeleteCity(2);

            aze.ListCities();

            int[]  a       = new int[];
            City[] elovset = new City[];
예제 #3
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);
        }
예제 #4
0
        public void CountryAddCityPopulationExceedsCountryPopulationThrowsException()
        {
            Continent continent = new Continent("Azië");
            Country   country   = new Country("vietnam", 95540000, 331.212f, continent);
            City      city      = new City("Hanoi", 95540001, country);
            Action    act       = () => country.AddCity(city);

            act.Should().Throw <Exception>().WithMessage("population: 95540001 would exceed country's population: 95540000.");
        }
예제 #5
0
        public void CountryAddCityNormalTest()
        {
            Continent continent = new Continent("Azië");
            Country   country   = new Country("vietnam", 95540000, 331.212f, continent);
            City      city      = new City("Hanoi", 7520700, country);
            Action    act       = () => country.AddCity(city);

            act.Should().NotThrow();
            country.Cities.Count.Should().Be(1);
        }
예제 #6
0
파일: City.cs 프로젝트: matanzg/codecovered
        public virtual void AssignCountry(Country country)
        {
            Validate.ThatArgumentNotNull(() => country);

            if (Country == country)
                return;

            Country = country;
            Country.AddCity(this);
        }
예제 #7
0
        public static void InsertSomeData(ISessionFactory sessionFactory)
        {
            using (var session = sessionFactory.OpenSession())
            using (var tx = session.BeginTransaction())
            {
                var israel = new Country { Name = "Israel" };
                var telaviv = new City { Name = "TelAviv" };
                israel.AddCity(telaviv);

                session.Save(israel);

                var address = new Address { City = telaviv, Number = 100, PostalCode = 101, Street = "200" };
                var matan = new Person
                {
                    Gender = Gender.Male,
                    Name = "Matan",
                    HomeAddress = address
                };

                session.Save(matan);

                var store = new Store { Contact = matan, Name = "Main Office" };
                var branch1 = new Branch
                {
                    Address = address,
                    Manager = matan,
                    Name = "branch1",
                    Location = (Point)Default.GeometryFactory.CreatePoint(new Coordinate(32, 34))
                };

                var branch2 = new Branch
                {
                    Address = address,
                    Manager = matan,
                    Name = "branch2",
                    Location = (Point)Default.GeometryFactory.CreatePoint(new Coordinate(32.5, 34.5))
                };

                store.AddBranch(branch1);
                store.AddBranch(branch2);

                var milk = new Product { Name = "milk", UnitPrice = 10, Description = "moo" };
                var bread = new Product { Name = "bread", UnitPrice = 8, Description = "poof" };

                session.Save(milk);
                session.Save(bread);

                branch1.AddProductToInventory(milk, 10);
                branch1.AddProductToInventory(bread, 15);
                branch2.AddProductToInventory(milk, 20);

                session.Save(store);
                tx.Commit();
            }
        }
예제 #8
0
        public override void SetUp()
        {
            base.SetUp();
            DeleteBase("cyclic.ndb");
            var odb    = Open("cyclic.ndb");
            var brasil = new Country("Brasil");

            for (var i = 0; i < 10; i++)
            {
                var city = new City("city" + i);
                city.SetCountry(brasil);
                brasil.AddCity(city);
            }
            odb.Store(brasil);
            odb.Close();
        }
예제 #9
0
        static void Main()
        {
            Country myCountry = new Country();

            while (true)
            {
                var nextQuery = Console.ReadLine().Split(' ');
                if (nextQuery[0].ToLower() == "add_city")
                {
                    String name = nextQuery[1];

                    City myCity = new City(name);
                    bool ok     = myCountry.AddCity(myCity);
                    if (!ok)
                    {
                        continue;
                    }
                    Console.WriteLine("Okay, enter the population of a city");
                    Int32 amount = Int32.Parse(System.Console.ReadLine());
                    for (var i = 0; i < amount; ++i)
                    {
                        Citizen newCitizen = new Citizen();
                        myCity.AddCitizen(newCitizen);
                    }
                    Console.WriteLine("Now enter initial number of infected people");
                    amount = Int32.Parse(System.Console.ReadLine());
                    myCity.InitializeInfection(amount);
                    Console.WriteLine("And finally, enter initial budget of a city");
                    Double money = Double.Parse(System.Console.ReadLine());
                    myCity.Budget = amount;
                    Console.WriteLine("---------------------------------------------");
                }

                if (nextQuery[0].ToLower() == "update")
                {
                    myCountry.UpdateCitiesState();
                    Console.WriteLine(myCountry);
                }
            }
        }
예제 #10
0
        public static void InsertSomeData(ISessionFactory sessionFactory)
        {
            using (var session = sessionFactory.OpenSession())
                using (var tx = session.BeginTransaction())
                {
                    var israel = new Country {
                        Name = "Israel"
                    };
                    var telaviv = new City {
                        Name = "TelAviv"
                    };
                    israel.AddCity(telaviv);

                    session.Save(israel);

                    var address = new Address {
                        City = telaviv, Number = 100, PostalCode = 101, Street = "200"
                    };
                    var matan = new Person
                    {
                        Gender      = Gender.Male,
                        Name        = "Matan",
                        HomeAddress = address
                    };

                    session.Save(matan);

                    var store = new Store {
                        Contact = matan, Name = "Main Office"
                    };
                    var branch1 = new Branch
                    {
                        Address  = address,
                        Manager  = matan,
                        Name     = "branch1",
                        Location = (Point)Default.GeometryFactory.CreatePoint(new Coordinate(32, 34))
                    };

                    var branch2 = new Branch
                    {
                        Address  = address,
                        Manager  = matan,
                        Name     = "branch2",
                        Location = (Point)Default.GeometryFactory.CreatePoint(new Coordinate(32.5, 34.5))
                    };

                    store.AddBranch(branch1);
                    store.AddBranch(branch2);

                    var milk = new Product {
                        Name = "milk", UnitPrice = 10, Description = "moo"
                    };
                    var bread = new Product {
                        Name = "bread", UnitPrice = 8, Description = "poof"
                    };

                    session.Save(milk);
                    session.Save(bread);

                    branch1.AddProductToInventory(milk, 10);
                    branch1.AddProductToInventory(bread, 15);
                    branch2.AddProductToInventory(milk, 20);

                    session.Save(store);
                    tx.Commit();
                }
        }