RandomInt() public static method

public static RandomInt ( ) : int
return int
        public async Task TestPostPointsAsync_FromObject_AutogenRetention()
        {
            try
            {
                var client    = new InfluxDBClient(influxUrl, dbUName, dbpwd);
                var retention = new InfluxRetentionPolicy()
                {
                    Name = "autogen", DBName = dbName, Duration = TimeSpan.FromMinutes(0), IsDefault = true
                };
                var points = Enumerable.Range(0, 10).Select(i =>
                                                            new PointObjectWithObjectRetention
                {
                    Measurement = "RetentionTest",
                    Time        = DateTime.UtcNow.AddDays(-i),
                    Retention   = retention,
                    Precision   = TimePrecision.Milliseconds,
                    StringTag   = "FromObject",
                    IntTag      = DataGen.RandomInt(),
                    StringField = DataGen.RandomString(),
                    DoubleField = DataGen.RandomDouble(),
                    IntField    = DataGen.RandomInt(),
                    BoolField   = i % 2 == 0,
                });

                var r = await client.PostPointsAsync(dbName, points);

                Assert.IsTrue(r, "PostPointsAsync returned false");
            }
            catch (Exception e)
            {
                Assert.Fail($"Unexpected exception of type {e.GetType()} caught: {e.Message}");
                return;
            }
        }
        public async Task TestPostObjectPointAsync()
        {
            try
            {
                var client = new InfluxDBClient(influxUrl, dbUName, dbpwd);

                var point = new PointObjectWithStringRetention
                {
                    Time        = DateTime.UtcNow,
                    Measurement = measurementName,
                    Precision   = TimePrecision.Seconds,
                    StringTag   = "FromObject",
                    IntTag      = DataGen.RandomInt(),
                    StringField = DataGen.RandomString(),
                    DoubleField = DataGen.RandomDouble(),
                    IntField    = DataGen.RandomInt(),
                    BoolField   = true,
                };

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

                Assert.IsTrue(r, "PostPointAsync returned false");
            }
            catch (Exception e)
            {
                Assert.Fail($"Unexpected exception of type {e.GetType()} caught: {e.Message}");
                return;
            }
        }
        public async Task TestPostPointsAsync_PartialWrite()
        {
            var client = new InfluxDBClient(influxUrl, dbUName, dbpwd);
            var time   = DateTime.Now;
            var today  = DateTime.Now.ToShortDateString();
            var now    = DateTime.Now.ToShortTimeString();

            var points = new List <IInfluxDatapoint>();


            var valDouble = new InfluxDatapoint <double>();

            valDouble.UtcTimestamp = DateTime.UtcNow;
            valDouble.Tags.Add("TestDate", today);
            valDouble.Tags.Add("TestTime", now);
            valDouble.Fields.Add("Doublefield", DataGen.RandomDouble());
            valDouble.Fields.Add("Doublefield2", Double.NaN);
            valDouble.MeasurementName = measurementName;
            valDouble.Precision       = TimePrecision.Seconds;
            points.Add(valDouble);


            for (int i = 0; i < 5; i++)
            {
                var valInt = new InfluxDatapoint <int>();
                valInt.UtcTimestamp = DateTime.UtcNow.AddSeconds(-1 * DataGen.RandomInt(3600));
                valInt.Tags.Add("TestDate", today);
                valInt.Tags.Add("TestTime", now);
                valInt.Fields.Add("Intfield", DataGen.RandomInt());
                valInt.Fields.Add("Intfield2", DataGen.RandomInt());
                valInt.MeasurementName = measurementName;
                valInt.Precision       = TimePrecision.Seconds;
                points.Add(valInt);
            }

            valDouble = new InfluxDatapoint <double>();
            valDouble.UtcTimestamp = DateTime.UtcNow;
            valDouble.Tags.Add("TestDate", today);
            valDouble.Tags.Add("TestTime", now);
            valDouble.Fields.Add("Doublefield", DataGen.RandomDouble());
            valDouble.Fields.Add("Doublefield2", Double.NaN);
            valDouble.MeasurementName = measurementName;
            valDouble.Precision       = TimePrecision.Seconds;
            points.Add(valDouble);


            var r = await AssertEx.ThrowsAsync <InfluxDBException>(() => client.PostPointsAsync(dbName, points));
        }
        public async Task TestQueryMultiSeriesAsync_ToObject()
        {
            var client = new InfluxDBClient(influxUrl, dbUName, dbpwd);

            var tagId = DataGen.RandomString();

            var points = Enumerable.Range(0, 3).Select(i =>
                                                       new PointObjectWithStringRetention
            {
                Time        = DateTime.UtcNow,
                Measurement = measurementName,
                Precision   = TimePrecision.Nanoseconds,
                StringTag   = tagId,
                IntTag      = i,
                StringField = DataGen.RandomString(),
                DoubleField = DataGen.RandomDouble(),
                IntField    = DataGen.RandomInt(),
                BoolField   = i % 2 == 0,
            }
                                                       ).ToList();

            var postResult = await client.PostPointsAsync(dbName, points);

            Assert.IsTrue(postResult, "PostPointsAsync returned false");

            Stopwatch s = new Stopwatch();

            s.Start();
            var queryResult = await client.QueryMultiSeriesAsync <PointObjectWithStringRetention>(dbName, $"SELECT * from {measurementName} WHERE StringTag='{tagId}'");

            s.Stop();
            Debug.WriteLine($"Elapsed {s.ElapsedMilliseconds}ms");

            Assert.IsTrue(queryResult != null, "QueryMultiSeriesAsync returned null or invalid data");
            Assert.IsTrue(queryResult.Count == 1, "QueryMultiSeriesAsync returned invalid number of series");
            foreach (var point in points)
            {
                var matching = queryResult[0].Entries.FirstOrDefault(e => e.IntTag == point.IntTag);

                Assert.IsTrue(matching != null, $"Missing record corresponding to record {point.IntTag}");

                Assert.IsTrue(matching.StringField == point.StringField, $"Mismatching string field on record {point.IntTag}");
                Assert.IsTrue(Math.Abs(matching.DoubleField - point.DoubleField) < .0000001, $"Mismatching double field on record {point.IntTag}");
                Assert.IsTrue(matching.IntField == point.IntField, $"Mismatching int field on record {point.IntTag}");
                Assert.IsTrue(matching.BoolField == point.BoolField, $"Mismatching bool field on record {point.IntTag}");
            }
        }
        public async Task TestPostPointsAsync_Batch()
        {
            try
            {
                var client = new InfluxDBClient(influxUrl, dbUName, dbpwd);

                var points = new List <IInfluxDatapoint>();

                var today = DateTime.Now.ToShortDateString();
                var now   = DateTime.Now.ToShortTimeString();
                var start = DateTime.Now.AddDays(-5);
                var end   = DateTime.Now;

                for (int i = 0; i < 5000; i++)
                {
                    var valMixed = new InfluxDatapoint <InfluxValueField>();
                    valMixed.UtcTimestamp = DataGen.RandomDate(start, end);
                    valMixed.Tags.Add("TestDate", today);
                    valMixed.Tags.Add("TestTime", now);
                    valMixed.UtcTimestamp = DateTime.UtcNow;
                    valMixed.Fields.Add("Doublefield", new InfluxValueField(DataGen.RandomDouble()));
                    valMixed.Fields.Add("Stringfield", new InfluxValueField(DataGen.RandomString()));
                    valMixed.Fields.Add("Boolfield", new InfluxValueField(DateTime.Now.Ticks % 2 == 0));
                    valMixed.Fields.Add("Int Field", new InfluxValueField(DataGen.RandomInt()));
                    valMixed.MeasurementName = measurementName;
                    valMixed.Precision       = (TimePrecision)(DataGen.RandomInt() % 6) + 1;
                    points.Add(valMixed);
                }

                var r = await client.PostPointsAsync(dbName, points);

                Assert.IsTrue(points.TrueForAll(p => p.Saved == true), "PostPointsAsync did not save all points");
            }
            catch (Exception e)
            {
                Assert.Fail($"Unexpected exception of type {e.GetType()} caught: {e.Message}");
                return;
            }
        }
        public async Task TestPostPointsAsync()
        {
            try
            {
                var client = new InfluxDBClient(influxUrl, dbUName, dbpwd);
                var time   = DateTime.Now;
                var today  = DateTime.Now.ToShortDateString();
                var now    = DateTime.Now.ToShortTimeString();

                var points = new List <IInfluxDatapoint>();

                var valDouble = new InfluxDatapoint <double>();
                valDouble.UtcTimestamp = DateTime.UtcNow;
                valDouble.Tags.Add("TestDate", today);
                valDouble.Tags.Add("TestTime", now);
                valDouble.Fields.Add("Doublefield", DataGen.RandomDouble());
                valDouble.Fields.Add("Doublefield2", DataGen.RandomDouble());
                valDouble.MeasurementName = measurementName;
                valDouble.Precision       = TimePrecision.Nanoseconds;
                points.Add(valDouble);

                valDouble = new InfluxDatapoint <double>();
                valDouble.UtcTimestamp = DateTime.UtcNow;
                valDouble.Tags.Add("TestDate", today);
                valDouble.Tags.Add("TestTime", now);
                valDouble.Fields.Add("Doublefield", DataGen.RandomDouble());
                valDouble.Fields.Add("Doublefield2", DataGen.RandomDouble());
                valDouble.MeasurementName = measurementName;
                valDouble.Precision       = TimePrecision.Microseconds;
                points.Add(valDouble);

                var valInt = new InfluxDatapoint <int>();
                valInt.UtcTimestamp = DateTime.UtcNow;
                valInt.Tags.Add("TestDate", today);
                valInt.Tags.Add("TestTime", now);
                valInt.Fields.Add("Intfield", DataGen.RandomInt());
                valInt.Fields.Add("Intfield2", DataGen.RandomInt());
                valInt.MeasurementName = measurementName;
                valInt.Precision       = TimePrecision.Milliseconds;
                points.Add(valInt);

                valInt = new InfluxDatapoint <int>();
                valInt.UtcTimestamp = DateTime.UtcNow;
                valInt.Tags.Add("TestDate", today);
                valInt.Tags.Add("TestTime", now);
                valInt.Fields.Add("Intfield", DataGen.RandomInt());
                valInt.Fields.Add("Intfield2", DataGen.RandomInt());
                valInt.MeasurementName = measurementName;
                valInt.Precision       = TimePrecision.Seconds;
                points.Add(valInt);

                var valBool = new InfluxDatapoint <bool>();
                valBool.UtcTimestamp = DateTime.UtcNow;
                valBool.Tags.Add("TestDate", today);
                valBool.Tags.Add("TestTime", now);
                valBool.Fields.Add("Booleanfield", time.Ticks % 2 == 0);
                valBool.MeasurementName = measurementName;
                valBool.Precision       = TimePrecision.Minutes;
                points.Add(valBool);

                var valString = new InfluxDatapoint <string>();
                valString.UtcTimestamp = DateTime.UtcNow;
                valString.Tags.Add("TestDate", today);
                valString.Tags.Add("TestTime", now);
                valString.Fields.Add("Stringfield", DataGen.RandomString());
                valString.MeasurementName = measurementName;
                valString.Precision       = TimePrecision.Hours;
                points.Add(valString);


                var r = await client.PostPointsAsync(dbName, points);

                Assert.IsTrue(r, "PostPointsAsync retunred false");
            }
            catch (Exception e)
            {
                Assert.Fail($"Unexpected exception of type {e.GetType()} caught: {e.Message}");
                return;
            }
        }