Ejemplo n.º 1
0
        public override FakeRow Populate(GDID parentGdid)
        {
            int age = getFakeAge(parentGdid);

            ID          = parentGdid;
            Name        = NaturalTextGenerator.GenerateFullName(true);
            Age         = age;
            DOB         = DateTime.Now.AddYears(-age);
            Sex         = parentGdid.ID % 2 == 0 ? Sex.Male : Sex.Female;
            Income      = parentGdid.ID % 79 * 1000;
            Debt        = parentGdid.ID % 11 * 1000;
            Rating      = parentGdid.ID % 2 == 0 ? (double?)null : 3.25;
            Notes       = parentGdid.ToString();
            Voter       = parentGdid.ID % 2 == 0 ? (bool?)null : true;
            MilitarySvc = parentGdid.ID % 2 == 0 ? (bool?)null : false;
            Address1    = NaturalTextGenerator.GenerateAddressLine();
            Address2    = parentGdid.ID % 7 == 0 ? NaturalTextGenerator.GenerateAddressLine() : null;
            City        = NaturalTextGenerator.GenerateCityName();
            State       = "OH";
            Zip         = "44000" + parentGdid.ID % 999;
            Phone1      = "(555) 222-3222";
            Phone2      = parentGdid.ID % 3 == 0 ? "(555) 737-9789" : null;
            Email1      = NaturalTextGenerator.GenerateEMail();
            Email2      = parentGdid.ID % 5 == 0 ? NaturalTextGenerator.GenerateEMail() : null;
            URL         = parentGdid.ID % 2 == 0 ? "https://ibm.com/products/" + parentGdid.ID : null;
            Tags        = getFakeTags();
            return(this);
        }
Ejemplo n.º 2
0
        protected override void DoHandleWork(WorkContext work)
        {
            var cnt    = work.MatchedVars["cnt"].AsInt(10);
            var pretty = work.MatchedVars["pretty"].AsBool(true);

            if (cnt > 10000)
            {
                cnt = 10000;
            }
            if (cnt < 0)
            {
                cnt = 1;
            }

            var lst = new List <object>();

            for (var i = 0; i < cnt; i++)
            {
                lst.Add(new {
                    FirstName  = NaturalTextGenerator.GenerateFirstName(),
                    MiddleName = NaturalTextGenerator.GenerateFirstName(),
                    LastName   = NaturalTextGenerator.GenerateLastName(),
                    Address    = "{0}\n{1}".Args(NaturalTextGenerator.GenerateAddressLine(),
                                                 NaturalTextGenerator.GenerateUSCityStateZip()),
                    Email = NaturalTextGenerator.GenerateEMail()
                });
            }

            work.Response.WriteJSON(lst, pretty ?
                                    NFX.Serialization.JSON.JSONWritingOptions.PrettyPrint :
                                    NFX.Serialization.JSON.JSONWritingOptions.Compact);
        }
Ejemplo n.º 3
0
 public static N3_PartyAddress Make()
 {
     return(new N3_PartyAddress
     {
         AddressInformation1 = NaturalTextGenerator.GenerateAddressLine(),
         AddressInformation2 = NaturalTextGenerator.GenerateUSCityStateZip()
     });
 }
Ejemplo n.º 4
0
 public void GenerateAddressLines()
 {
     for (var i = 0; i < 100; i++)
     {
         var txt = NaturalTextGenerator.GenerateAddressLine();
         Console.WriteLine(txt);
         Assert.IsTrue(txt.IsNotNullOrWhiteSpace());
         Assert.IsTrue(txt.Length >= 3);
         Assert.IsTrue(txt.Length <= 100);
     }
 }
        public static Address Build()
        {
            var rnd = ExternalRandomGenerator.Instance.NextRandomInteger;

            return(new Address
            {
                Address1 = NaturalTextGenerator.GenerateAddressLine(),
                Address2 = (0 != (rnd & (1 << 15))) ? NaturalTextGenerator.GenerateAddressLine() : null,
                City = NaturalTextGenerator.GenerateCityName(),
                State = NaturalTextGenerator.GenerateCityName(),
                PostalCode = rnd.ToString(),
                CanAcceptSecureShipments = rnd > 0,
                EMail = rnd < -500000000 ? NaturalTextGenerator.GenerateEMail() : null,
                HomePhone = (0 != (rnd & (1 << 32))) ? "(555) 111-22234" : null,
                CellPhone = (0 != (rnd & (1 << 31))) ? "(555) 234-22234" : null,
                Fax = (0 != (rnd & (1 << 30))) ? "(555) 111-22239" : null
            });
        }
Ejemplo n.º 6
0
        public void PerfFullInfo()
        {
            const int CNT = 1000000;
            var       sw  = Stopwatch.StartNew();

            for (var i = 0; i < CNT; i++)
            {
                var name = NaturalTextGenerator.GenerateFirstName() + " " + NaturalTextGenerator.GenerateLastName();
                var addr = NaturalTextGenerator.GenerateAddressLine();
                var csz  = NaturalTextGenerator.GenerateUSCityStateZip();
            }

            var elapsed = sw.ElapsedMilliseconds;
            var ops     = CNT / (elapsed / 1000d);

            Console.WriteLine("Genereated {0} full infos, in {1:n0} ms at {2:n0} ops/sec", CNT, elapsed, ops);
            Assert.IsTrue(ops > 180000);//180,000 ops/sec
        }
Ejemplo n.º 7
0
        public void PerfFullInfo_Parallel()
        {
            const int CNT = 3000000;
            var       sw  = Stopwatch.StartNew();

            System.Threading.Tasks.Parallel.For(0, CNT,
                                                (i) =>
            {
                var name = NaturalTextGenerator.GenerateFirstName() + " " + NaturalTextGenerator.GenerateLastName();
                var addr = NaturalTextGenerator.GenerateAddressLine();
                var csz  = NaturalTextGenerator.GenerateUSCityStateZip();
            });

            var elapsed = sw.ElapsedMilliseconds;
            var ops     = CNT / (elapsed / 1000d);

            Assert.IsTrue(ops > 750000);//750,000 ops/sec

            Console.WriteLine("Genereated {0} full infos, in {1:n0} ms at {2:n0} ops/sec", CNT, elapsed, ops);
        }
Ejemplo n.º 8
0
 public void GenerateFullInfo()
 {
     for (var i = 0; i < 100; i++)
     {
         var name = NaturalTextGenerator.GenerateFirstName() + " " + NaturalTextGenerator.GenerateLastName();
         var addr = NaturalTextGenerator.GenerateAddressLine();
         var csz  = NaturalTextGenerator.GenerateUSCityStateZip();
         Console.WriteLine(name);
         Console.WriteLine(addr);
         Console.WriteLine(csz);
         Console.WriteLine("-------------------------------------------");
         Assert.IsTrue(name.IsNotNullOrWhiteSpace());
         Assert.IsTrue(addr.IsNotNullOrWhiteSpace());
         Assert.IsTrue(csz.IsNotNullOrWhiteSpace());
         Assert.IsTrue(name.Length >= 3);
         Assert.IsTrue(name.Length <= 100);
         Assert.IsTrue(addr.Length >= 3);
         Assert.IsTrue(addr.Length <= 100);
         Assert.IsTrue(csz.Length >= 3);
         Assert.IsTrue(csz.Length <= 100);
     }
 }
Ejemplo n.º 9
0
        public static TypicalPersonData MakeRandom()
        {
            var rnd = ExternalRandomGenerator.Instance.NextRandomInteger;

            var data = new TypicalPersonData
            {
                FirstName  = NaturalTextGenerator.GenerateFirstName(),
                MiddleName =
                    ExternalRandomGenerator.Instance.NextRandomInteger > 500000000
                        ? NaturalTextGenerator.GenerateFirstName()
                        : null,
                LastName         = NaturalTextGenerator.GenerateLastName(),
                DOB              = DateTime.Now.AddYears(ExternalRandomGenerator.Instance.NextScaledRandomInteger(-90, -1)),
                Salary           = ExternalRandomGenerator.Instance.NextScaledRandomInteger(30, 250) * 1000m,
                YearsOfService   = 25,
                CreditScore      = 0.7562,
                RegisteredToVote = (DateTime.UtcNow.Ticks & 1) == 0,
                MaritalStatus    = MaritalStatus.HatesAll,
                Address1         = NaturalTextGenerator.GenerateAddressLine(),
                Address2         = NaturalTextGenerator.GenerateAddressLine(),
                AddressCity      = NaturalTextGenerator.GenerateCityName(),
                AddressState     = "CA",
                AddressZip       = "91606",
                HomePhone        = (DateTime.UtcNow.Ticks & 1) == 0 ? "(555) 123-4567" : null,
                EMail            = NaturalTextGenerator.GenerateEMail()
            };

            if (0 != (rnd & (1 << 32)))
            {
                data.Notes = NaturalTextGenerator.Generate(45);
            }
            if (0 != (rnd & (1 << 31)))
            {
                data.SkypeID = NaturalTextGenerator.GenerateEMail();
            }
            if (0 != (rnd & (1 << 30)))
            {
                data.YahooID = NaturalTextGenerator.GenerateEMail();
            }

            if (0 != (rnd & (1 << 29)))
            {
                data.IsSmoker = 0 != (rnd & (1 << 17));
            }
            if (0 != (rnd & (1 << 28)))
            {
                data.IsLoving = 0 != (rnd & (1 << 16));
            }
            if (0 != (rnd & (1 << 27)))
            {
                data.IsLoved = 0 != (rnd & (1 << 15));
            }
            if (0 != (rnd & (1 << 26)))
            {
                data.IsDangerous = 0 != (rnd & (1 << 14));
            }
            if (0 != (rnd & (1 << 25)))
            {
                data.IsEducated = 0 != (rnd & (1 << 13));
            }

            if (0 != (rnd & (1 << 24)))
            {
                data.LastSmokingDate = DateTime.Now.AddYears(-10);
            }


            if (0 != (rnd & (1 << 23)))
            {
                data.DesiredSalary = rnd / 1000m;
            }
            if (0 != (rnd & (1 << 22)))
            {
                data.ProbabilityOfSpaceFlight = rnd / (double)int.MaxValue;
            }

            if (0 != (rnd & (1 << 21)))
            {
                data.CurrentFriendCount = rnd % 123;
                data.DesiredFriendCount = rnd % 121000;
            }

            return(data);
        }
Ejemplo n.º 10
0
        //   public object SomeObject;

        public static TypicalPersonData MakeRandom(bool extraData = false)
        {
            var rnd = ExternalRandomGenerator.Instance.NextRandomInteger;

            var data = new TypicalPersonData
            {
                FirstName        = NaturalTextGenerator.GenerateFirstName(),
                MiddleName       = ExternalRandomGenerator.Instance.NextRandomInteger > 500000000 ? NaturalTextGenerator.GenerateFirstName() : null,
                LastName         = NaturalTextGenerator.GenerateLastName(),
                DOB              = DateTime.Now.AddYears(ExternalRandomGenerator.Instance.NextScaledRandomInteger(-90, -1)),
                Salary           = ExternalRandomGenerator.Instance.NextScaledRandomInteger(30, 250) * 1000m,
                YearsOfService   = 25,
                CreditScore      = 0.7562,
                RegisteredToVote = (DateTime.UtcNow.Ticks & 1) == 0,
                MaritalStatus    = MaritalStatus.HatesAll,
                Address1         = NaturalTextGenerator.GenerateAddressLine(),
                Address2         = NaturalTextGenerator.GenerateAddressLine(),
                AddressCity      = NaturalTextGenerator.GenerateCityName(),
                AddressState     = "CA",
                AddressZip       = "91606",
                HomePhone        = (DateTime.UtcNow.Ticks & 1) == 0 ? "(555) 123-4567" : null,
                EMail            = NaturalTextGenerator.GenerateEMail()
            };

            //if (extraData)
            //  data.SomeObject = new Dictionary<object, object>
            //  {
            //    { "1aaaaa", TypicalPersonData.MakeRandom(false)}, { 2212, -234123}, {13000,100}, { Tuple.Create(2, false,true), "yes"}, {"4aaa",'a'},
            //    { "a2aaaa", TypicalPersonData.MakeRandom(false)}, { 132, TypicalPersonData.MakeRandom(false)}, {130400,100}, { Tuple.Create(3, false,true), "yes"}, {"a234aa",'a'},
            //    { "aa4aaa", TypicalPersonData.MakeRandom(false)}, { 412, -123}, {2100d,100L}, { Tuple.Create(4, false,TypicalPersonData.MakeRandom(false)), "yes"}, {"a5aa",'a'},
            //    { "aa3aaa", TypicalPersonData.MakeRandom(false)}, { 212, 0}, {1222200m,100}, { Tuple.Create(5, false,true), "yes"}, {"a43aa1",'a'},
            //    { "a5aaaa", TypicalPersonData.MakeRandom(false)}, { 512, new int[]{1,2,-3,4,5,-6,-1,-2,-3,-4,5,6,1,2,3,4,5,6,1,2,3,4,5,6,1,2,3,4,5,60}},
            //    {102200,100}, { Tuple.Create(-213232d, false,false), "yes"}, {"222222222222aaa",'a'},
            //  };

            if (0 != (rnd & (1 << 32)))
            {
                data.Notes = NaturalTextGenerator.Generate(45);
            }
            if (0 != (rnd & (1 << 31)))
            {
                data.SkypeID = NaturalTextGenerator.GenerateEMail();
            }
            if (0 != (rnd & (1 << 30)))
            {
                data.YahooID = NaturalTextGenerator.GenerateEMail();
            }

            if (0 != (rnd & (1 << 29)))
            {
                data.IsSmoker = 0 != (rnd & (1 << 17));
            }
            if (0 != (rnd & (1 << 28)))
            {
                data.IsLoving = 0 != (rnd & (1 << 16));
            }
            if (0 != (rnd & (1 << 27)))
            {
                data.IsLoved = 0 != (rnd & (1 << 15));
            }
            if (0 != (rnd & (1 << 26)))
            {
                data.IsDangerous = 0 != (rnd & (1 << 14));
            }
            if (0 != (rnd & (1 << 25)))
            {
                data.IsEducated = 0 != (rnd & (1 << 13));
            }

            if (0 != (rnd & (1 << 24)))
            {
                data.LastSmokingDate = DateTime.Now.AddYears(-10);
            }


            if (0 != (rnd & (1 << 23)))
            {
                data.DesiredSalary = rnd / 1000m;
            }
            if (0 != (rnd & (1 << 22)))
            {
                data.ProbabilityOfSpaceFlight = rnd / (double)int.MaxValue;
            }

            if (0 != (rnd & (1 << 21)))
            {
                data.CurrentFriendCount = rnd % 123;
                data.DesiredFriendCount = rnd % 121000;
            }


            return(data);
        }