public void TestAdd()
        {
            int countAfterAdd = 1;

            collection.Add(country);
            Assert.AreEqual(countAfterAdd, collection.GetCollection().Count);
        }
 public void CantAddDuplicateCountriesToCollection()
 {
     var c = new Country("MEE");
     var c2 = new Country("MEE");
     var collection = new CountryCollection();
     collection.Add(c);
     Assert.That(() => collection.Add(c2), Throws.ArgumentException);
 }
 public void CanAddCountriesToCollection()
 {
     var c = new Country("MEE");
     var collection = new CountryCollection();
     collection.Add(c);
     Assert.That(collection.Count(), Is.EqualTo(1));
 }
Ejemplo n.º 4
0
        private static CountryCollection DBMapping(DBCountryCollection dbCollection)
        {
            if (dbCollection == null)
                return null;

            CountryCollection collection = new CountryCollection();
            foreach (DBCountry dbItem in dbCollection)
            {
                Country item = DBMapping(dbItem);
                collection.Add(item);
            }

            return collection;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Loads a collection of Country objects from the database.
        /// </summary>
        /// <returns>A collection containing all of the Country objects in the database.</returns>
        public static CountryCollection LoadCollection(string spName, SqlParameter[] parms)
        {
            CountryCollection result = new CountryCollection();

            using (SqlDataReader reader = SqlHelper.Default.ExecuteReader(spName, parms))
            {
                while (reader.Read())
                {
                    Country tmp = new Country();
                    tmp.LoadFromReader(reader);
                    result.Add(tmp);
                }
            }
            return(result);
        }
Ejemplo n.º 6
0
        public static CountryCollection GetAllItem()
        {
            CountryCollection collection = new CountryCollection();

            using (var reader = SqlHelper.ExecuteReader("tblCountry_GetAll", null))
            {
                while (reader.Read())
                {
                    Country obj = new Country();
                    obj = GetItemFromReader(reader);
                    collection.Add(obj);
                }
            }
            return(collection);
        }
Ejemplo n.º 7
0
        private static CountryCollection DBMapping(DBCountryCollection dbCollection)
        {
            if (dbCollection == null)
            {
                return(null);
            }

            CountryCollection collection = new CountryCollection();

            foreach (DBCountry dbItem in dbCollection)
            {
                Country item = DBMapping(dbItem);
                collection.Add(item);
            }

            return(collection);
        }
Ejemplo n.º 8
0
        private void Button_AddCountry_Click(object sender, EventArgs e)
        {
            string countryCode = textBox_CountryCode.Text;
            string countryName = textBox_CountryName.Text;

            try
            {
                Country country = new Country(countryCode, countryName);
                countryCollection.Add(country);
                RefreshListCountry();
                textBox_CountryCode.Clear();
                textBox_CountryName.Clear();
            }
            catch (ArgumentOutOfRangeException ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 9
0
    public void CoAIsOutputtedForCountryWithFlagSet()
    {
        var titles = new Title.LandedTitles();

        var countries     = new CountryCollection();
        var countryReader = new BufferedReader("tag=ADI flag=testFlag");
        var country       = Country.Parse(countryReader, 1);

        countries.Add(country);

        const string outputModName = "outputMod";
        var          outputPath    = Path.Combine("output", outputModName, "common", "coat_of_arms", "coat_of_arms", "fromImperator.txt");

        SystemUtils.TryCreateFolder(CommonFunctions.GetPath(outputPath));

        titles.ImportImperatorCountries(countries,
                                        new TagTitleMapper(),
                                        new LocDB("english"),
                                        new ProvinceMapper(),
                                        new CoaMapper("TestFiles/imperatorCoAs.txt"),
                                        new GovernmentMapper(),
                                        new SuccessionLawMapper(),
                                        new DefiniteFormMapper(),
                                        new ReligionMapper(),
                                        new CultureMapper(),
                                        new NicknameMapper(),
                                        new CharacterCollection(),
                                        new Date(400, 1, 1)
                                        );

        CoatOfArmsOutputter.OutputCoas(outputModName, titles);

        using var file = File.OpenRead(outputPath);
        var reader = new StreamReader(file);

        Assert.Equal("d_IMPTOCK3_ADI={", reader.ReadLine());
        Assert.Equal("\tpattern=\"pattern_solid.tga\"", reader.ReadLine());
        Assert.Equal("\tcolor1=red color2=green color3=blue", reader.ReadLine());
        Assert.Equal("}", reader.ReadLine());
    }
Ejemplo n.º 10
0
    public void CoAIsNotOutputtedForCountryWithoutFlagSet()
    {
        var titles = new Title.LandedTitles();

        var countries     = new CountryCollection();
        var countryReader = new BufferedReader("tag=BDI");
        var country       = Country.Parse(countryReader, 2);

        countries.Add(country);

        const string outputModName = "outputMod";
        var          outputPath    = Path.Combine("output", outputModName, "common", "coat_of_arms", "coat_of_arms", "fromImperator.txt");

        SystemUtils.TryCreateFolder(CommonFunctions.GetPath(outputPath));

        titles.ImportImperatorCountries(countries,
                                        new TagTitleMapper(),
                                        new LocDB("english"),
                                        new ProvinceMapper(),
                                        new CoaMapper("TestFiles/imperatorCoAs.txt"),
                                        new GovernmentMapper(),
                                        new SuccessionLawMapper(),
                                        new DefiniteFormMapper(),
                                        new ReligionMapper(),
                                        new CultureMapper(),
                                        new NicknameMapper(),
                                        new CharacterCollection(),
                                        new Date(400, 1, 1)
                                        );

        CoatOfArmsOutputter.OutputCoas(outputModName, titles);

        using var file = File.OpenRead(outputPath);
        var reader = new StreamReader(file);

        Assert.True(reader.EndOfStream);
    }
        private void SetupReferenceData()
        {
            var countries = new Country { CountryId = "1", Name = "USA", Code = "USA" };

            var states = new State { StateId = "2", CountryId = "1", Name = "Florida" };

            var ports = new Port { PortId = "1", City = "Florida", Name = "Miami", State = "Florida", StateId = "2", CountryId = "1" };

            var brands = new Brand { BrandId = "1", Name = "Carnival" };

            var personTypes = new PersonTypeEntity { PersonTypeId = "1001", Name = "Daniel" };

            var loyaltyLevelTypes = new LoyaltyLevelType { LoyaltyLevelTypeId = "1001", Name = "abc", BrandId = "1", NoOfCruiseNights = 3, LogoImageAddress = "abc" };

            var documentType = new DocumentType { CountryId = "232", Code = "USA", DocumentTypeId = "1", Name = "Passport" };

            var brand = new BrandCollection();

            var country = new CountryCollection();
            country.Add(countries);

            var state = new StateCollection();
            state.Add(states);

            var documentTypes = new DocumentTypeCollection();
            documentTypes.Add(documentType);

            var port = new PortCollection();
            port.Add(ports);

            var personTypeEntity = new PersonTypeEntityCollection();
            personTypeEntity.Add(personTypes);

            var loyaltyLevelType = new LoyaltyLevelTypeCollection();
            loyaltyLevelType.Add(loyaltyLevelTypes);

            this.referenceData.AssignBrands(brand);
            this.referenceData.AssignCountries(country);
            this.referenceData.AssignStates(state);
            this.referenceData.AssignDocumentTypes(documentTypes);
            this.referenceData.AssignLoyaltyLevelTypes(loyaltyLevelType);
            this.referenceData.AssignPersonTypes(personTypeEntity);
            this.referenceData.AssignPorts(port);
        }
        /// <summary>
        /// Function to retrieve country collection
        /// </summary>
        /// <param name="queryCountries">countries query</param>
        /// <returns>country collection</returns>
        private static CountryCollection RetriveCountryCollection(IEnumerable<Country> queryCountries)
        {
            CountryCollection countryCollection = new CountryCollection();
            foreach (Country country in queryCountries)
            {
                countryCollection.Add(country);
            }

            return countryCollection;
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Maps the countries.
        /// </summary>
        /// <param name="dataReader">The data reader.</param>
        /// <returns>Country collection</returns>
        private static async Task<CountryCollection> MapCountries(SqlDataReader dataReader)
        {
            var countryCollection = new CountryCollection();
            if (dataReader != null)
            {
                while (await dataReader.ReadAsync())
                {
                    var country = new Country
                    {
                        CountryId = dataReader.Int32Field(CountryId).ToString(),
                        Code = dataReader.StringField(Code),
                        Name = dataReader.StringField(Name),
                        CountryFlagAddress = dataReader.StringField(CountryFlagAddress)
                    };

                    byte[] bytes = await country.CountryFlagAddress.ImageAddressToByteArray();
                    country.CountryIcon = bytes.ToBitmapSource();
                    countryCollection.Add(country);
                }
            }

            return countryCollection;
        }