コード例 #1
0
        public virtual Serie PointToSerie(Point point)
        {
            var s = new Serie
            {
                Name = point.Name
            };

            foreach (var key in point.Tags.Keys.ToList())
            {
                s.Tags.Add(key, point.Tags[key].ToString());
            }

            var sortedFields = point.Fields.OrderBy(k => k.Key).ToDictionary(x => x.Key, x => x.Value);

            s.Columns = new string[] { "time" }.Concat(sortedFields.Keys).ToArray();

            s.Values = new object[][]
            {
                new object[] { point.Timestamp }.Concat(sortedFields.Values).ToArray()
            };

            return s;
        }
コード例 #2
0
        private async Task<List<Serie>> Query(Serie expected)
        {
            // 0.9.3 need 'group by' to retrieve tags as tags when using select *
            var result = await _influx.QueryAsync(_dbName, String.Format("select * from \"{0}\" group by *", expected.Name));

            result.Should().NotBeNull();
            result.Count().Should().Be(1);

            var actual = result.Single();

            actual.Name.Should().Be(expected.Name);
            actual.Tags.Count.Should().Be(expected.Tags.Count);
            actual.Tags.ShouldAllBeEquivalentTo(expected.Tags);
            actual.Columns.ShouldAllBeEquivalentTo(expected.Columns);
            actual.Columns.Count().Should().Be(expected.Columns.Count());
            actual.Values[0].Count().Should().Be(expected.Values[0].Count());
            ((DateTime)actual.Values[0][0]).ToUnixTime().Should().Be(((DateTime)expected.Values[0][0]).ToUnixTime());

            return result;
        }