AdysTech.InfluxDB.Client.Net.Tests.DataGen.RandomString C# (CSharp) Method

RandomString() public static method

public static RandomString ( ) : string
return string
        public static string RandomString()
        {
            var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 ,=/";
            var stringChars = new StringBuilder (16, 16);

            for ( int i = 0; i < stringChars.Capacity; i++ )
            {
                lock ( syncLock )
                {
                    stringChars.Append(chars[random.Next (chars.Length)]);
                }
            }
            return stringChars.ToString (); ;
        }

Usage Example

        public async Task TestPostPointAsyncNonDefaultRetention()
        {
            try
            {
                var client   = new InfluxDBClient(influxUrl, dbUName, dbpwd);
                var time     = DateTime.Now;
                var rand     = new Random();
                var valMixed = new InfluxDatapoint <InfluxValueField>();
                valMixed.UtcTimestamp = DateTime.UtcNow;
                valMixed.Tags.Add("TestDate", time.ToShortDateString());
                valMixed.Tags.Add("TestTime", time.ToShortTimeString());
                valMixed.Fields.Add("Doublefield", new InfluxValueField(rand.NextDouble()));
                valMixed.Fields.Add("Stringfield", new InfluxValueField(DataGen.RandomString()));
                valMixed.Fields.Add("Boolfield", new InfluxValueField(true));
                valMixed.Fields.Add("Int Field", new InfluxValueField(rand.Next()));

                valMixed.MeasurementName = measurementName;
                valMixed.Precision       = TimePrecision.Seconds;
                valMixed.Retention       = new InfluxRetentionPolicy()
                {
                    Duration = TimeSpan.FromHours(6)
                };

                var r = await client.PostPointAsync(dbName, valMixed);

                Assert.IsTrue(r && valMixed.Saved, "PostPointAsync retunred false");
            }
            catch (Exception e)
            {
                Assert.Fail($"Unexpected exception of type {e.GetType()} caught: {e.Message}");
                return;
            }
        }
All Usage Examples Of AdysTech.InfluxDB.Client.Net.Tests.DataGen::RandomString