private EntityCollection GenerateRandomAccountCollection() { var collection = new List<Entity>(); for (var i = 0; i < 10; i++) { var rgn = new Random((int)DateTime.Now.Ticks); var entity = new Entity("account"); entity["accountid"] = entity.Id = Guid.NewGuid(); entity["address1_addressid"] = Guid.NewGuid(); entity["modifiedon"] = DateTime.Now; entity["lastusedincampaign"] = DateTime.Now; entity["donotfax"] = rgn.NextBoolean(); entity["new_verybignumber"] = rgn.NextInt64(); entity["exchangerate"] = rgn.NextDecimal(); entity["address1_latitude"] = rgn.NextDouble(); entity["numberofemployees"] = rgn.NextInt32(); entity["primarycontactid"] = new EntityReference("contact", Guid.NewGuid()); entity["revenue"] = new Money(rgn.NextDecimal()); entity["ownerid"] = new EntityReference("systemuser", Guid.NewGuid()); entity["industrycode"] = new OptionSetValue(rgn.NextInt32()); entity["name"] = rgn.NextString(15); entity["description"] = rgn.NextString(300); entity["statecode"] = new OptionSetValue(rgn.NextInt32()); entity["statuscode"] = new OptionSetValue(rgn.NextInt32()); collection.Add(entity); } return new EntityCollection(collection); }
public void String_Length() { Distribution( 10, 1_000_000, () => r.NextString(500).Length / 50 ); }
private static async Task RedisClusterAsync() { var redisCluster = await Cluster.From(_host, _port, GetClusterConfiguration()); var tasks = new List<Task>(); for (var x = 0; x < 50; x++) { var threadnum = x; tasks.Add(Task.Run(async () => { try { for (var i = 0; i < 100; i++) { var rand = new Random(_seed + threadnum); for (var s = 0; s < 10; s++) { var key = rand.NextString(150); var max = 1; if (HashSlot.For(key).ToInt() < HashSlot.SlotCount/2) max = 70; for (var it = 0; it < max; it++) { Write(await redisCluster.SendAsync( ClusterCommand.From("SET", key, rand.NextString(50)), MasterSlavePreference.Either)); Write(await redisCluster.SendAsync( ClusterCommand.From("GET", key), MasterSlavePreference.Either)); } } } } catch (Exception e) { Console.WriteLine("EXCEPTION: " + e.Message); throw; } finally { Console.WriteLine("THREAD EXIT"); } })); } var t = new Timer((a) => { Console.WriteLine("Time for new bytes!"); _seed++; }, new {}, 0, 30000); Task.WaitAll(tasks.ToArray()); }
public void GetNextStringTest() { int expectedLenght = 1000; var random = new Random(); string actual = random.NextString(expectedLenght); Assert.AreEqual(expectedLenght, actual.Length); }
public void NextString_LengthGreaterThanZero() { Random r = new Random(); string str = r.NextString(10); Assert.AreEqual(str.Length, 10); }
public void NextString_LengthZero() { Random r = new Random(); string str = r.NextString(0); Assert.AreEqual(str, string.Empty); }
public static List<TestEntity> GenerateRandomTestEntities(int sampleSize) { Random random = new Random(); List<TestEntity> testEntities = new List<TestEntity>(); for (int i = 0; i < sampleSize; i++) { testEntities.Add(new TestEntity { TestDate = random.NextDateTime(new DateTime(2000, 1, 1), new DateTime(2012, 1, 1)), TestInt = random.Next(), TestString = random.NextString(1000) }); } return testEntities; }
/// <summary> /// Gets a randomly constructed string. /// </summary> /// <param name="r">A <see cref="System.Random"/> instance.</param> /// <param name="boundChr1">A digit value bound that represents a Unicode character.</param> /// <param name="boundChr2">Another digit value bound that represents a Unicode character.</param> /// <param name="minlen">The minimum length of the output string.</param> /// <param name="maxlen">The maximum length of the output string.</param> /// <returns>The random output string.</returns> public static string NextString(this Random r, char boundChr1, char boundChr2, int minlen, int maxlen) { return(r.NextString(boundChr1, boundChr2, (new Random()).Next(minlen, maxlen + 1))); }
public static Parameter GetOne(System.Random rnd) { return (new Parameter { ItemType = "Parameter", Key = rnd.Next(), Name = rnd.NextString(), Revision = rnd.Next(), SequenceId = rnd.Next(), Description = rnd.NextString(), Units = rnd.NextString(), Prop1 = rnd.NextBoolean(), Prop2 = rnd.NextBoolean(), Prop3 = rnd.NextBoolean(), Prop4 = rnd.NextBoolean(), Prop5 = rnd.NextBoolean(), Prop6 = rnd.NextString(), Prop7 = rnd.NextBoolean(), Prop8 = rnd.NextDouble(), Prop9 = rnd.NextString(), Prop10 = rnd.NextString(), Prop11 = rnd.NextBoolean(), Prop12 = rnd.Next(), Prop13 = rnd.NextString(), Prop14 = rnd.Next(), Prop15 = rnd.NextString(), Prop16 = rnd.NextString(), Prop17 = rnd.NextString(), Prop18 = rnd.NextString(), Prop19 = rnd.NextString(), Prop20 = rnd.NextString(), Prop21 = rnd.NextString(), Prop22 = rnd.NextString(), Prop23 = rnd.NextBoolean(), Prop24 = rnd.NextBoolean(), Prop25 = rnd.NextBoolean(), Prop26 = rnd.NextBoolean(), Prop27 = rnd.NextBoolean(), Prop28 = rnd.NextBoolean(), Prop29 = rnd.NextBoolean(), Prop30 = rnd.NextBoolean(), Prop31 = rnd.NextDouble(), Prop32 = rnd.NextDouble(), Prop33 = rnd.NextBoolean(), Prop34 = rnd.NextBoolean(), Prop35 = rnd.NextBoolean(), Prop36 = rnd.NextString(), Prop37 = rnd.NextBoolean(), Prop38 = rnd.NextBoolean(), Prop39 = rnd.NextBoolean(), Prop40 = rnd.NextBoolean(), Prop45 = rnd.NextString(), Prop46 = rnd.NextBoolean(), Prop47 = rnd.NextBoolean(), Prop48 = rnd.NextBoolean(), Prop49 = rnd.NextBoolean(), Prop50 = rnd.Next() }); }
private static string RandomPhone(int seed) { Random r = new Random(seed); return r.NextString(10, "0123456789"); }
private static AddressEntity RandomAddress(int seed) { Random r = new Random(seed); return new AddressEntity { Address = r.NextElement(new[] { "Madison Av.", "Sessame Str.", "5th Av.", "Flamingo Way" }) + " " + r.Next(100), City = r.NextElement(new[] { "New York", "Los Angeles", "Miami", "Seattle" }), Country = "USA", Region = r.NextElement(new[] { "NY", "FL", "WA", "CA" }), PostalCode = r.NextString(5, "0123456789") }; }
public MockHttpServerUtility() { Random rand = new Random(); tmpDirectory = Path.Combine(Path.GetTempPath(), rand.NextString(5, 6, "qwertyuiopasdfghjklzxcvbnm")); Directory.CreateDirectory(tmpDirectory); }
public void NextString_LengthLessThanZero() { Random r = new Random(); r.NextString(-1); }
private void RptInvoiceControl_Load(object sender, EventArgs e) { Random random = new Random(); this.invoiceNo = random.NextString(10); etNo.Text = this.invoiceNo; }