Exemplo n.º 1
0
        public Address GetAddress(Age age)
        {
            Address address = new Address();
            address.Country = GetRandom(_countries);

            if (address.Country == "Australia")
            {
                address.Street = GetRandom(_auStreets);
                address.State = GetRandom(_auStates);
                Address rndSuburb = GetRandom(_auSuburbs.Where(a => a.State == address.State));
                address.Suburb = rndSuburb.Suburb;
                address.PostCode = rndSuburb.PostCode;
            }
            else if (address.Country == "England")
            {
                address.Street = GetRandom(_gbStreets);
                address.Suburb = GetRandom(_gbSuburbs);
            }
            else
            {
                address.Street = GetRandom(_nzStreets);
                Address rndSuburb = GetRandom(_nzSuburbs);
                address.Suburb = rndSuburb.Suburb;
                address.PostCode = rndSuburb.PostCode;
            }

            address.Number = _rand.Next(1, 100).ToString();

            double rnd = _rand.NextDouble();
            if ((age == Age.Range1 && rnd < 0.2)
                || (age == Age.Range2 && rnd < 0.3)
                || (age == Age.Range3 && rnd < 0.1)
                || (age == Age.Range4 && rnd < 0.1)
                || (age == Age.Range5 && rnd < 0.1)
                || (age == Age.Range6 && rnd < 0.25)
                )
            {
                Tuple<int, int> value = GetRandom(_unitNumbers);
                address.Unit = _rand.Next(value.Item1, value.Item2).ToString();
            }

            return address;
        }
Exemplo n.º 2
0
 public Address[] ReadNzSuburbs(string file)
 {
     List<Address> suburbs = new List<Address>();
     using (TextReader reader = File.OpenText(file))
     {
         string line;
         while ((line = reader.ReadLine()) != null)
         {
             string[] split = line.Split('\t');
             Address address = new Address()
             {
                 Suburb = split[0],
                 PostCode = split[1]
             };
             suburbs.Add(address);
         }
     }
     return suburbs.ToArray();
 }