/// <summary>
 /// Formats the specified field.
 /// </summary>
 /// <param name="field">
 /// It's the field to format.
 /// </param>
 /// <param name="formatterContext">
 /// It's the context of formatting to be used by the method.
 /// </param>
 public override void Format(Field field, ref FormatterContext formatterContext)
 {
     if (_evaluator.EvaluateFormat(field, ref formatterContext))
     {
         _trueFormatter.Format(field, ref formatterContext);
     }
     else
     {
         _falseFormatter.Format(field, ref formatterContext);
     }
 }
        public void FormatTest()
        {
            FieldInfo fieldInfo = default;

            string actual = FieldFormatter.Format(fieldInfo);

            string expected = default;

            Assert.That(actual, Is.EqualTo(expected));
            Assert.Fail("autogenerated");
        }
Beispiel #3
0
        public static string Serialize(InfluxPoint point)
        {
            var tags   = point.Tags;
            var fields = point.Fields;

            var allTags   = string.Join(",", TagsFormatter.Format(tags));
            var allFields = string.Join(",", FieldFormatter.Format(fields));

            var tagsPart = allTags.Length > 0 ? $",{allTags}" : allTags;

            var measurement = KeyFormatter.Format(point.Measurement);

            return($"{measurement}{tagsPart} {allFields} {FieldValueFormatter.FormatTimestamp(point.UtcTimestamp)}".Trim());
        }
        public void test_formatter_format_correctly_to_upper_underscore_from_upper_camel()
        {
            var formatter = new FieldFormatter("UppER_UNDERSCORE");

            formatter.Format("HolaDonPepito").Should().BeEquivalentTo("HOLA_DON_PEPITO");
        }
        public void test_formatter_format_correctly_to_upper_camel_from_lower_camel()
        {
            var formatter = new FieldFormatter(FieldFormatterType.UPPER_CAMEL);

            formatter.Format("holaDonPepito").Should().BeEquivalentTo("HolaDonPepito");
        }
        public void test_formatter_format_correctly_to_upper_camel_from_all_upper()
        {
            var formatter = new FieldFormatter(FieldFormatterType.UPPER_CAMEL);

            formatter.Format("HOLADONPEPITO").Should().BeEquivalentTo("HOLADONPEPITO");
        }
        public void test_formatter_format_correctly_to_lower_underscore_from_upper_camel()
        {
            var formatter = new FieldFormatter("lower_underscore");

            formatter.Format("HolaDonPepito").Should().BeEquivalentTo("hola_don_pepito");
        }
        public void test_formatter_format_correctly_to_lower_underscore_from_mixed_string()
        {
            var formatter = new FieldFormatter(FieldFormatterType.LOWER_UNDERSCORE);

            formatter.Format("Hola_don-Pepito").Should().BeEquivalentTo("hola_don_pepito");
        }
        public void test_formatter_format_correctly_to_lower_hyphen_from_upper_camel()
        {
            var formatter = new FieldFormatter("LOWER_HYPHEN");

            formatter.Format("HolaDonPepito").Should().BeEquivalentTo("hola-don-pepito");
        }
        public void test_formatter_format_correctly_to_lower_hyphen_from_mixed_string()
        {
            var formatter = new FieldFormatter(FieldFormatterType.LOWER_HYPHEN);

            formatter.Format("Hola_don-Pepito").Should().BeEquivalentTo("hola-don-pepito");
        }
        public void test_formatter_format_correctly_to_inherited_from_upper_camel()
        {
            var formatter = new FieldFormatter(FieldFormatterType.INHERITED);

            formatter.Format("HolaDonPepito").Should().BeEquivalentTo("HolaDonPepito");
        }
        public string Sweep(string fields)
        {
            var processedFields = _fieldSplitter.TransformRawFields(fields);

            return(_fieldFormatter.Format(processedFields));
        }