Пример #1
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);
        }
Пример #2
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);
        }
Пример #3
0
 public static CommunicationNumber Make()
 {
     return(new CommunicationNumber
     {
         Communication_Number_Qualifier = "QW",
         Communication_Number = NaturalTextGenerator.GenerateEMail()
     });
 }
Пример #4
0
 public void GenerateEMails()
 {
     for (var i = 0; i < 100; i++)
     {
         var txt = NaturalTextGenerator.GenerateEMail();
         Console.WriteLine(txt);
         Assert.IsTrue(txt.IsNotNullOrWhiteSpace());
         Assert.IsTrue(txt.Length >= 3);
         Assert.IsTrue(txt.Length <= 100);
     }
 }
Пример #5
0
 public static RDM_RemittanceDeliveryMethod Make()
 {
     return(new RDM_RemittanceDeliveryMethod
     {
         Report_Transmission_Code = NaturalTextGenerator.GenerateWord(),
         Name = NaturalTextGenerator.GenerateFullName(),
         Communication_Number = NaturalTextGenerator.GenerateEMail(),
         Info1 = NaturalTextGenerator.Generate(50),
         Info2 = NaturalTextGenerator.Generate(20)
     });
 }
Пример #6
0
 public override FakeRow Populate(GDID parentGdid)
 {
     ID          = parentGdid;
     DisplayName = NaturalTextGenerator.GenerateFullName(true);
     FromEmail   = NaturalTextGenerator.GenerateEMail();
     ToEmail     = NaturalTextGenerator.GenerateEMail();
     CcEmail     = parentGdid.ID % 5 == 0 ? NaturalTextGenerator.GenerateEMail() : null;
     BccEmail    = parentGdid.ID % 10 == 0 ? NaturalTextGenerator.GenerateEMail() : null;
     Host        = $"127.0.0.{Ambient.Random.NextScaledRandomInteger(1, 20)}";
     Tags        = getFakeTags();
     SentDate    = DateTime.Now.AddHours(Ambient.Random.NextScaledRandomInteger(1, 12)).AddMinutes(Ambient.Random.NextScaledRandomInteger(1, 60));
     Subject     = NaturalTextGenerator.Generate(50);
     Body        = NaturalTextGenerator.Generate(0);
     return(this);
 }
Пример #7
0
 public static PER_ClaimContactInformation Make()
 {
     return(new PER_ClaimContactInformation
     {
         Contact_Function_Code = "CFC",
         Name = NaturalTextGenerator.GenerateFullName(),
         Communication_Number_Qualifier = "DL",
         Communication_Numbers =
             new List <string>
         {
             NaturalTextGenerator.GenerateEMail(),
             NaturalTextGenerator.GenerateEMail(),
             NaturalTextGenerator.GenerateEMail()
         },
         Contact_Inquiry_Reference = NaturalTextGenerator.GenerateWord()
     });
 }
        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
            });
        }
Пример #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);
        }
Пример #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);
        }