@@ -49,8 +49,6 @@ public async Task HistogramFormat_Test()
4949 using MemoryStream stream = await GetMetrics ( payload ) ;
5050 List < string > lines = ReadStream ( stream ) ;
5151
52- // Question - this is manually recreating what PrometheusDataModel.GetPrometheusNormalizedName does to get the metric name;
53- // should we call this method, or should this also be implicitly testing its behavior by having this hard-coded?
5452 string metricName = $ "{ MeterName . ToLowerInvariant ( ) } _{ payload [ 0 ] . Name } ";
5553
5654 const string quantile_50 = "{quantile=\" 0.5\" }" ;
@@ -74,8 +72,6 @@ public async Task GaugeFormat_Test()
7472
7573 List < string > lines = ReadStream ( stream ) ;
7674
77- // Question - this is manually recreating what PrometheusDataModel.GetPrometheusNormalizedName does to get the metric name;
78- // should we call this method, or should this also be implicitly testing its behavior by having this hard-coded?
7975 string metricName = $ "{ MeterName . ToLowerInvariant ( ) } _{ payload . Name } ";
8076
8177 Assert . Equal ( 3 , lines . Count ) ;
@@ -93,8 +89,6 @@ public async Task CounterFormat_Test()
9389
9490 List < string > lines = ReadStream ( stream ) ;
9591
96- // Question - this is manually recreating what PrometheusDataModel.GetPrometheusNormalizedName does to get the metric name;
97- // should we call this method, or should this also be implicitly testing its behavior by having this hard-coded?
9892 string metricName = $ "{ MeterName . ToLowerInvariant ( ) } _{ payload . Name } ";
9993
10094 Assert . Equal ( 3 , lines . Count ) ;
@@ -103,6 +97,23 @@ public async Task CounterFormat_Test()
10397 Assert . Equal ( $ "{ metricName } { payload . Value } { new DateTimeOffset ( payload . Timestamp ) . ToUnixTimeMilliseconds ( ) } ", lines [ 2 ] ) ;
10498 }
10599
100+ [ Fact ]
101+ public async Task UpDownCounterFormat_Test ( )
102+ {
103+ ICounterPayload payload = new UpDownCounterPayload ( MeterName , InstrumentName , "DisplayName" , "" , null , Value1 , Timestamp ) ;
104+
105+ MemoryStream stream = await GetMetrics ( new ( ) { payload } ) ;
106+
107+ List < string > lines = ReadStream ( stream ) ;
108+
109+ string metricName = $ "{ MeterName . ToLowerInvariant ( ) } _{ payload . Name } ";
110+
111+ Assert . Equal ( 3 , lines . Count ) ;
112+ Assert . Equal ( FormattableString . Invariant ( $ "# HELP { metricName } { payload . Unit } { payload . DisplayName } ") , lines [ 0 ] ) ;
113+ Assert . Equal ( FormattableString . Invariant ( $ "# TYPE { metricName } gauge") , lines [ 1 ] ) ;
114+ Assert . Equal ( FormattableString . Invariant ( $ "{ metricName } { payload . Value } { new DateTimeOffset ( payload . Timestamp ) . ToUnixTimeMilliseconds ( ) } ") , lines [ 2 ] ) ;
115+ }
116+
106117 private async Task < MemoryStream > GetMetrics ( List < ICounterPayload > payloads )
107118 {
108119 IMetricsStore metricsStore = new MetricsStore ( _logger , MetricCount ) ;
0 commit comments