コード例 #1
0
ファイル: FakeRow.cs プロジェクト: azist/azos
        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);
        }
コード例 #2
0
 public void GenerateCityNames()
 {
     for (var i = 0; i < 100; i++)
     {
         var txt = NaturalTextGenerator.GenerateCityName();
         Console.WriteLine(txt);
         Assert.IsTrue(txt.IsNotNullOrWhiteSpace());
         Assert.IsTrue(txt.Length >= 3);
         Assert.IsTrue(txt.Length <= 40);
     }
 }
コード例 #3
0
 //makes fake weather data for the day
 private WeatherDay makeFake(DateTime when, string area)
 {
     return(new WeatherDay
     {
         AsOfDate = when,
         LocalityName = "{0} near {1}".Args(area, NaturalTextGenerator.GenerateCityName()),
         PrecipitationChance = ExternalRandomGenerator.Instance.NextScaledRandomInteger(0, 100),
         TemperatureLowF = ExternalRandomGenerator.Instance.NextScaledRandomInteger(42, 50),
         TemperatureHighF = ExternalRandomGenerator.Instance.NextScaledRandomInteger(62, 74),
     });
 }
コード例 #4
0
 public static N4_PartyCity_State_ZIPCode Make()
 {
     return(new N4_PartyCity_State_ZIPCode
     {
         City_Name = NaturalTextGenerator.GenerateCityName(),
         State_or_Province_Code = "CA",
         Postal_Code = "98155",
         Country_Code = "USA",
         Location_Qualifier = "LA",
         Location_Identifier = "1234567.12",
         Country_Subdivision_Code = "WW"
     });
 }
コード例 #5
0
        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
            });
        }
コード例 #6
0
        public void AnalyzeUniqueness(int CNT)
        {
            var fnames  = new List <string>();
            var lnames  = new List <string>();
            var flnames = new List <string>();
            var cities  = new List <string>();

            for (var i = 0; i < CNT; i++)
            {
                var fn = NaturalTextGenerator.GenerateFirstName();
                fnames.Add(fn);
                var ln = NaturalTextGenerator.GenerateLastName();
                lnames.Add(ln);
                flnames.Add(fn + " " + ln);
                cities.Add(NaturalTextGenerator.GenerateCityName());
            }
            Console.WriteLine("Generated {0:n0} times", CNT);
            Console.WriteLine("----------------------------");
            var dfn = fnames.Distinct().Count();
            var pfn = 100d * (dfn / (double)CNT);

            Console.WriteLine(" First names {0:n0} unique {1:n3}%", dfn, pfn);

            var dln = lnames.Distinct().Count();
            var pln = 100d * (dln / (double)CNT);

            Console.WriteLine(" Last names {0:n0} unique {1:n3}%", dln, pln);

            var dfln = flnames.Distinct().Count();
            var pfln = 100d * (dfln / (double)CNT);

            Console.WriteLine(" First+Last names {0:n0} unique {1:n3}%", dfln, pfln);
            Assert.IsTrue(pfln > 85d);//85% uniqueness

            var dct = cities.Distinct().Count();
            var pct = 100d * (dct / (double)CNT);

            Console.WriteLine(" Cities {0:n0} unique {1:n3}%", dct, pct);
            Console.WriteLine();
        }
コード例 #7
0
        private User makeUser(long id)
        {
            var chance = ExternalRandomGenerator.Instance.NextRandomInteger;

            var now  = App.TimeSource.UTCNow;
            var user = new User
            {
                ID               = id,
                Name             = "User Joe " + id.ToString(),
                RegistrationDate = now,
                LastLoginDate    = now,
                EMail            = id.ToString() + "mydomain.com",
                CanVote          = (chance & 1) == 0
            };

            if (chance > 500000000)
            {
                user.Location = NaturalTextGenerator.GenerateCityName();
            }

            return(user);
        }
コード例 #8
0
ファイル: TypicalPerson.cs プロジェクト: marcosnz/serbench
        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);
        }
コード例 #9
0
ファイル: TypicalPerson.cs プロジェクト: ddpruitt/serbench
        //   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);
        }