public void InfluxTag_CanParse_InvalidValueReturnsEmpty()
        {
            // invalid input strings
            InfluxTag empty      = InfluxTag.Empty;
            String    nullReason = "Because the input string should contain a single key and value separated by an equals sign.";

            InfluxUtils.ToInfluxTag("key").Should().Be(empty, nullReason);
            InfluxUtils.ToInfluxTag("key=").Should().Be(empty, nullReason);
            InfluxUtils.ToInfluxTag("=value").Should().Be(empty, nullReason);
            InfluxUtils.ToInfluxTag("key=value1=value2").Should().Be(empty, nullReason);
            InfluxUtils.ToInfluxTag("key,value").Should().Be(empty, nullReason);
            InfluxUtils.ToInfluxTag("key==").Should().Be(empty, nullReason);
            InfluxUtils.ToInfluxTag("==val").Should().Be(empty, nullReason);
        }
示例#2
0
        /// <summary>
        /// Formats the measurement name, tag keys, and field keys on the specified <see cref="InfluxRecord"/>
        /// with the defined tag and key formatters and returns the same record instance.
        /// </summary>
        /// <param name="record">The <see cref="InfluxRecord"/> to format the tag and field keys for.</param>
        /// <returns>The same <see cref="InfluxRecord"/> instance with the tag and field keys formatted.</returns>
        public virtual InfluxRecord FormatRecord(InfluxRecord record)
        {
            record.Name = FormatMetricName(null, record.Name, Unit.None, null) ?? record.Name;

            for (int i = 0; i < record.Tags.Count; i++)
            {
                InfluxTag tag    = record.Tags[i];
                String    fmtKey = FormatTagKey(tag.Key);
                record.Tags[i] = new InfluxTag(fmtKey, tag.Value);
            }

            for (int i = 0; i < record.Fields.Count; i++)
            {
                InfluxField field  = record.Fields[i];
                String      fmtKey = FormatFieldKey(field.Key);
                record.Fields[i] = new InfluxField(fmtKey, field.Value);
            }

            return(record);
        }
 public void InfluxTag_FormatsTo_LineProtocol(InfluxTag tag, String output)
 {
     tag.ToLineProtocol().Should().Be(output);
     tag.ToString().Should().Be(output);
 }
示例#4
0
 public TagTestCase(InfluxTag tag, String output)
 {
     Tag    = tag;
     Output = output;
 }