|
1 | 1 | // Copyright The OpenTelemetry Authors
|
2 | 2 | // SPDX-License-Identifier: Apache-2.0
|
3 | 3 |
|
| 4 | +using Xunit; |
| 5 | + |
4 | 6 | namespace OpenTelemetry.Metrics.Tests;
|
5 | 7 |
|
6 | 8 | public class MetricTestData
|
7 | 9 | {
|
8 |
| - public static IEnumerable<object[]> InvalidInstrumentNames |
9 |
| - => new List<object[]> |
10 |
| - { |
11 |
| - new object[] { " " }, |
12 |
| - new object[] { "-first-char-not-alphabetic" }, |
13 |
| - new object[] { "1first-char-not-alphabetic" }, |
14 |
| - new object[] { "invalid+separator" }, |
15 |
| - new object[] { new string('m', 256) }, |
16 |
| - new object[] { "a\xb5" }, // `\xb5` is the Micro character |
17 |
| - }; |
| 10 | + public static TheoryData<string> InvalidInstrumentNames |
| 11 | + => |
| 12 | + [ |
| 13 | + " ", |
| 14 | + "-first-char-not-alphabetic", |
| 15 | + "1first-char-not-alphabetic", |
| 16 | + "invalid+separator", |
| 17 | + new('m', 256), |
| 18 | + "a\xb5", // `\xb5` is the Micro character |
| 19 | + ]; |
18 | 20 |
|
19 |
| - public static IEnumerable<object[]> ValidInstrumentNames |
20 |
| - => new List<object[]> |
21 |
| - { |
22 |
| - new object[] { "m" }, |
23 |
| - new object[] { "first-char-alphabetic" }, |
24 |
| - new object[] { "my-2-instrument" }, |
25 |
| - new object[] { "my.metric" }, |
26 |
| - new object[] { "my_metric2" }, |
27 |
| - new object[] { new string('m', 255) }, |
28 |
| - new object[] { "CaSe-InSeNsItIvE" }, |
29 |
| - new object[] { "my_metric/environment/database" }, |
30 |
| - }; |
| 21 | + public static TheoryData<string> ValidInstrumentNames |
| 22 | + => |
| 23 | + [ |
| 24 | + "m", |
| 25 | + "first-char-alphabetic", |
| 26 | + "my-2-instrument", |
| 27 | + "my.metric", |
| 28 | + "my_metric2", |
| 29 | + new('m', 255), |
| 30 | + "CaSe-InSeNsItIvE", |
| 31 | + "my_metric/environment/database", |
| 32 | + ]; |
31 | 33 |
|
32 |
| - public static IEnumerable<object[]> InvalidHistogramBoundaries |
33 |
| - => new List<object[]> |
34 |
| - { |
35 |
| - new object[] { new double[] { 0, 0 } }, |
36 |
| - new object[] { new double[] { 1, 0 } }, |
37 |
| - new object[] { new double[] { 0, 1, 1, 2 } }, |
38 |
| - new object[] { new double[] { 0, 1, 2, -1 } }, |
39 |
| - }; |
| 34 | + public static TheoryData<double[]> InvalidHistogramBoundaries |
| 35 | + => |
| 36 | + [ |
| 37 | + [0.0, 0.0], |
| 38 | + [1.0, 0.0], |
| 39 | + [0.0, 1.0, 1.0, 2.0], |
| 40 | + [0.0, 1.0, 2.0, -1.0], |
| 41 | + ]; |
40 | 42 |
|
41 |
| - public static IEnumerable<object[]> ValidHistogramMinMax |
42 |
| - => new List<object[]> |
43 |
| - { |
44 |
| - new object[] { new double[] { -10, 0, 1, 9, 10, 11, 19 }, new HistogramConfiguration(), -10, 19 }, |
45 |
| - new object[] { new double[] { double.NegativeInfinity }, new HistogramConfiguration(), double.NegativeInfinity, double.NegativeInfinity }, |
46 |
| - new object[] { new double[] { double.NegativeInfinity, 0, double.PositiveInfinity }, new HistogramConfiguration(), double.NegativeInfinity, double.PositiveInfinity }, |
47 |
| - new object[] { new double[] { 1 }, new HistogramConfiguration(), 1, 1 }, |
48 |
| - new object[] { new double[] { 5, 100, 4, 101, -2, 97 }, new ExplicitBucketHistogramConfiguration() { Boundaries = [10.0, 20.0] }, -2, 101 }, |
49 |
| - new object[] { new double[] { 5, 100, 4, 101, -2, 97 }, new Base2ExponentialBucketHistogramConfiguration(), 4, 101 }, |
50 |
| - }; |
| 43 | + public static TheoryData<double[], HistogramConfiguration, double, double> ValidHistogramMinMax => |
| 44 | + new() |
| 45 | + { |
| 46 | + { [-10.0, 0.0, 1.0, 9.0, 10.0, 11.0, 19.0], new HistogramConfiguration(), -10.0, 19.0 }, |
| 47 | + { [double.NegativeInfinity], new HistogramConfiguration(), double.NegativeInfinity, double.NegativeInfinity }, |
| 48 | + { [double.NegativeInfinity, 0.0, double.PositiveInfinity], new HistogramConfiguration(), double.NegativeInfinity, double.PositiveInfinity }, |
| 49 | + { [1.0], new HistogramConfiguration(), 1.0, 1.0 }, |
| 50 | + { [5.0, 100.0, 4.0, 101.0, -2.0, 97.0], new ExplicitBucketHistogramConfiguration { Boundaries = [10.0, 20.0] }, -2.0, 101.0 }, |
| 51 | + { [5.0, 100.0, 4.0, 101.0, -2.0, 97.0], new Base2ExponentialBucketHistogramConfiguration(), 4.0, 101.0 }, |
| 52 | + }; |
51 | 53 |
|
52 |
| - public static IEnumerable<object[]> InvalidHistogramMinMax |
53 |
| - => new List<object[]> |
| 54 | + public static TheoryData<double[], HistogramConfiguration> InvalidHistogramMinMax |
| 55 | + => new() |
54 | 56 | {
|
55 |
| - new object[] { new double[] { 1 }, new HistogramConfiguration() { RecordMinMax = false } }, |
56 |
| - new object[] { new double[] { 1 }, new ExplicitBucketHistogramConfiguration() { Boundaries = [10.0, 20.0], RecordMinMax = false } }, |
57 |
| - new object[] { new double[] { 1 }, new Base2ExponentialBucketHistogramConfiguration() { RecordMinMax = false } }, |
| 57 | + { [1.0], new HistogramConfiguration { RecordMinMax = false } }, |
| 58 | + { [1.0], new ExplicitBucketHistogramConfiguration { Boundaries = [10.0, 20.0], RecordMinMax = false } }, |
| 59 | + { [1.0], new Base2ExponentialBucketHistogramConfiguration { RecordMinMax = false } }, |
58 | 60 | };
|
59 | 61 | }
|
0 commit comments