示例#1
0
        public void TestToString()
        {
            var d = new LabelDict("foo");

            Assert.That(d.ToString(null), Is.EqualTo("environment=\"foo\""));
            Assert.That(d.ToString(""), Is.EqualTo("environment=\"foo\""));
            Assert.That(d.ToString("123"), Is.EqualTo("environment=\"foo\",le=\"123\""));

            d = new LabelDict("foo\nbar");
            Assert.That(d.ToString(null), Is.EqualTo("environment=\"foo\\nbar\""));

            d = new LabelDict("foo\"bar");
            Assert.That(d.ToString(null), Is.EqualTo("environment=\"foo\\\"bar\""));

            d = new LabelDict("foo\\bar");
            Assert.That(d.ToString(null), Is.EqualTo("environment=\"foo\\\\bar\""));

            d = new LabelDict("foo");
            d.Set("a", "b");
            Assert.That(d.ToString(null), Is.EqualTo("environment=\"foo\",a=\"b\""));
        }
示例#2
0
 protected string QualifiedName([CanBeNull] string le = null)
 {
     return($"{_metricBase.PrefixedName}{{{Labels.ToString(le)}}}");
 }