Skip to content

Commit 7521728

Browse files
authored
[repo] Bump test packages (#6157)
1 parent 71e6cb4 commit 7521728

File tree

5 files changed

+54
-52
lines changed

5 files changed

+54
-52
lines changed

Directory.Packages.props

+2-2
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@
109109
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="$(LatestRuntimeOutOfBandVer)" />
110110
<PackageVersion Include="Microsoft.Extensions.Telemetry.Abstractions" Version="[9.0.0,)" />
111111
<PackageVersion Include="Microsoft.NETFramework.ReferenceAssemblies" Version="[1.0.3,2.0)" />
112-
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="[17.11.0,18.0.0)" />
112+
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="[17.13.0,18.0.0)" />
113113
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="[8.0.0,9.0)" />
114114
<PackageVersion Include="MinVer" Version="[5.0.0,6.0)" />
115115
<PackageVersion Include="NuGet.Versioning" Version="6.11.0" />
@@ -121,7 +121,7 @@
121121
<PackageVersion Include="StyleCop.Analyzers" Version="[1.2.0-beta.556,2.0)" />
122122
<PackageVersion Include="Swashbuckle.AspNetCore" Version="[6.7.3,)" />
123123
<PackageVersion Include="System.Runtime.InteropServices.RuntimeInformation" Version="4.3.0" />
124-
<PackageVersion Include="xunit" Version="[2.9.0,3.0)" />
124+
<PackageVersion Include="xunit" Version="[2.9.3,3.0)" />
125125
<PackageVersion Include="xunit.runner.visualstudio" Version="[2.8.2,3.0)" />
126126
</ItemGroup>
127127

test/OpenTelemetry.Tests/Metrics/MetricApiTests.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ public void MetricInstrumentationScopeIsExportedCorrectly()
188188

189189
Assert.NotNull(metric.MeterTags);
190190

191-
Assert.Single(metric.MeterTags.Where(kvp => kvp.Key == meterTags[0].Key && kvp.Value == meterTags[0].Value));
191+
Assert.Single(metric.MeterTags, kvp => kvp.Key == meterTags[0].Key && kvp.Value == meterTags[0].Value);
192192
}
193193

194194
[Fact]
@@ -584,7 +584,7 @@ public void MeterSourcesWildcardSupportMatchTest(bool hasView)
584584

585585
meterProvider.ForceFlush(MaxTimeToAllowForFlush);
586586

587-
Assert.True(exportedItems.Count == 5); // "SomeCompany.SomeProduct.SomeComponent" will not be subscribed.
587+
Assert.Equal(5, exportedItems.Count); // "SomeCompany.SomeProduct.SomeComponent" will not be subscribed.
588588

589589
if (hasView)
590590
{
@@ -629,7 +629,7 @@ public void MeterSourcesWildcardSupportNegativeTestNoMeterAdded(bool hasView)
629629
meter2.CreateObservableGauge("myGauge2", () => measurement);
630630

631631
meterProvider.ForceFlush(MaxTimeToAllowForFlush);
632-
Assert.True(exportedItems.Count == 0);
632+
Assert.Empty(exportedItems);
633633
}
634634

635635
[Theory]
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,61 @@
11
// Copyright The OpenTelemetry Authors
22
// SPDX-License-Identifier: Apache-2.0
33

4+
using Xunit;
5+
46
namespace OpenTelemetry.Metrics.Tests;
57

68
public class MetricTestData
79
{
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+
];
1820

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+
];
3133

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+
];
4042

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+
};
5153

52-
public static IEnumerable<object[]> InvalidHistogramMinMax
53-
=> new List<object[]>
54+
public static TheoryData<double[], HistogramConfiguration> InvalidHistogramMinMax
55+
=> new()
5456
{
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 } },
5860
};
5961
}

test/OpenTelemetry.Tests/Metrics/MetricViewTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public void AddViewWithExceptionInUserCallbackNoDefault()
137137
{
138138
var counter1 = meter1.CreateCounter<long>("counter1");
139139
counter1.Add(1);
140-
Assert.Single(inMemoryEventListener.Events.Where((e) => e.EventId == 41));
140+
Assert.Single(inMemoryEventListener.Events, e => e.EventId == 41);
141141
}
142142

143143
meterProvider.ForceFlush(MaxTimeToAllowForFlush);

test/OpenTelemetry.Tests/Resources/ResourceBuilderTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public void ServiceResource_ServiceName()
1313
var resource = ResourceBuilder.CreateEmpty().AddService("my-service").Build();
1414
Assert.Equal(2, resource.Attributes.Count());
1515
Assert.Contains(new KeyValuePair<string, object>(ResourceSemanticConventions.AttributeServiceName, "my-service"), resource.Attributes);
16-
Assert.Single(resource.Attributes.Where(kvp => kvp.Key == ResourceSemanticConventions.AttributeServiceName));
16+
Assert.Single(resource.Attributes, kvp => kvp.Key == ResourceSemanticConventions.AttributeServiceName);
1717
Assert.True(Guid.TryParse((string)resource.Attributes.Single(kvp => kvp.Key == ResourceSemanticConventions.AttributeServiceInstance).Value, out _));
1818
}
1919

0 commit comments

Comments
 (0)