Skip to content

Commit a11c74b

Browse files
committed
Remove use of FluentAssertions
1 parent ade4cd4 commit a11c74b

12 files changed

+105
-112
lines changed

tests/AutoInstrumentation.IntegrationTests/PluginLoaderTests.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// See the LICENSE file in the project root for more information
44

55
using System.Runtime.InteropServices;
6-
using FluentAssertions;
76
using Nullean.Xunit.Partitions.Sdk;
87
using Xunit;
98

@@ -15,12 +14,13 @@ public class PluginLoaderTests(ExampleApplicationContainer exampleApplicationCon
1514
public async Task ObserveDistributionPluginLoad()
1615
{
1716
await Task.Delay(TimeSpan.FromSeconds(3));
17+
1818
var output = exampleApplicationContainer.FailureTestOutput();
19-
output.Should()
20-
.NotBeNullOrWhiteSpace()
21-
.And.Contain("Elastic Distribution of OpenTelemetry .NET:")
22-
.And.Contain("ElasticOpenTelemetryBuilder initialized")
23-
.And.Contain("Added 'Elastic.OpenTelemetry.Processors.ElasticCompatibilityProcessor'");
19+
20+
Assert.False(string.IsNullOrWhiteSpace(output));
21+
Assert.Contains("Elastic Distribution of OpenTelemetry (EDOT) .NET:", output);
22+
Assert.Contains("ElasticOpenTelemetryBuilder initialized", output);
23+
Assert.Contains("Added 'Elastic.OpenTelemetry.Processors.ElasticCompatibilityProcessor'", output);
2424
}
2525
}
2626

tests/Directory.Build.props

+3-8
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,12 @@
2222
</PropertyGroup>
2323

2424
<ItemGroup Condition="$([System.Text.RegularExpressions.Regex]::IsMatch($(ProjectName), '^(.*)Tests$'))">
25-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
26-
25+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
2726
<PackageReference Include="GitHubActionsTestLogger" Version="2.4.1" PrivateAssets="All" />
2827
<PackageReference Include="JunitXml.TestLogger" Version="3.1.12" PrivateAssets="All" />
2928
<PackageReference Include="Nullean.VsTest.Pretty.TestLogger" Version="0.4.0" PrivateAssets="All" />
30-
31-
<PackageReference Include="FluentAssertions" Version="6.12.0" />
32-
<PackageReference Include="FluentAssertions.Analyzers" Version="0.31.0" />
33-
34-
<PackageReference Include="xunit" Version="2.7.0" />
35-
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.7">
29+
<PackageReference Include="xunit" Version="2.9.3" />
30+
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
3631
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
3732
<PrivateAssets>all</PrivateAssets>
3833
</PackageReference>

tests/Elastic.OpenTelemetry.EndToEndTests/DistributedFixture/ITrafficSimulator.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// See the LICENSE file in the project root for more information
44

55
using System.Net;
6-
using FluentAssertions;
6+
using Xunit;
77

88
namespace Elastic.OpenTelemetry.EndToEndTests.DistributedFixture;
99

@@ -19,7 +19,7 @@ public async Task Start(DistributedApplicationFixture distributedInfra)
1919
for (var i = 0; i < 10; i++)
2020
{
2121
var get = await distributedInfra.AspNetApplication.HttpClient.GetAsync("e2e");
22-
get.StatusCode.Should().Be(HttpStatusCode.OK);
22+
Assert.Equal(HttpStatusCode.OK, get.StatusCode);
2323
_ = await get.Content.ReadAsStringAsync();
2424
}
2525
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<TargetFramework>net9.0</TargetFramework>
@@ -11,12 +11,12 @@
1111
</PropertyGroup>
1212

1313
<ItemGroup>
14-
<PackageReference Include="Microsoft.Playwright" Version="1.49.0" />
14+
<PackageReference Include="Microsoft.Playwright" Version="1.50.0" />
1515
<PackageReference Include="Nullean.Xunit.Partitions" Version="0.5.0" />
16-
<PackageReference Include="Proc" Version="0.8.2" />
17-
<PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.0" />
18-
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="9.0.0" />
19-
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="9.0.0" />
16+
<PackageReference Include="Proc" Version="0.9.1" />
17+
<PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.2" />
18+
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="9.0.2" />
19+
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="9.0.2" />
2020
</ItemGroup>
2121

2222
</Project>

tests/Elastic.OpenTelemetry.EndToEndTests/EndToEndOptions.cs

+5-10
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
using Elastic.OpenTelemetry.EndToEndTests;
66
using Elastic.OpenTelemetry.EndToEndTests.DistributedFixture;
7-
using FluentAssertions;
87
using Microsoft.Extensions.Configuration;
98
using Nullean.Xunit.Partitions;
109
using Xunit;
@@ -29,19 +28,15 @@ public override void OnBeforeTestsRun()
2928
if (testSuite == null || (
3029
!testSuite.Equals("e2e", StringComparison.InvariantCultureIgnoreCase)
3130
&& !testSuite.Equals("all", StringComparison.InvariantCultureIgnoreCase))
32-
)
31+
)
3332
return;
3433

3534
try
3635
{
37-
configuration["E2E:Endpoint"].Should()
38-
.NotBeNullOrWhiteSpace("Missing E2E:Endpoint configuration");
39-
configuration["E2E:Authorization"].Should()
40-
.NotBeNullOrWhiteSpace("Missing E2E:Authorization configuration");
41-
configuration["E2E:BrowserEmail"].Should()
42-
.NotBeNullOrWhiteSpace("Missing E2E:BrowserEmail configuration");
43-
configuration["E2E:BrowserPassword"].Should()
44-
.NotBeNullOrWhiteSpace("Missing E2E:BrowserPassword configuration");
36+
Assert.False(string.IsNullOrWhiteSpace(configuration["E2E:Endpoint"]), userMessage: "Missing E2E:Endpoint configuration");
37+
Assert.False(string.IsNullOrWhiteSpace(configuration["E2E:Authorization"]), userMessage: "Missing E2E:Authorization configuration");
38+
Assert.False(string.IsNullOrWhiteSpace(configuration["E2E:BrowserEmail"]), userMessage: "Missing E2E:BrowserEmail configuration");
39+
Assert.False(string.IsNullOrWhiteSpace(configuration["E2E:BrowserPassword"]), userMessage: "Missing E2E:BrowserPassword configuration");
4540
}
4641
catch (Exception e)
4742
{

tests/Elastic.OpenTelemetry.EndToEndTests/ServiceTests.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// See the LICENSE file in the project root for more information
44

55
using Elastic.OpenTelemetry.EndToEndTests.DistributedFixture;
6-
using FluentAssertions;
76
using Microsoft.Playwright;
87
using Nullean.Xunit.Partitions.Sdk;
98
using Xunit;
@@ -20,7 +19,7 @@ public class EndToEndTests(ITestOutputHelper output, DistributedApplicationFixtu
2019
private IPage _page = null!;
2120

2221
[Fact]
23-
public void EnsureApplicationWasStarted() => fixture.Started.Should().BeTrue();
22+
public void EnsureApplicationWasStarted() => Assert.True(fixture.Started);
2423

2524
[Fact]
2625
public async Task LatencyShowsAGraph()

tests/Elastic.OpenTelemetry.Tests/AutoInstrumentationPluginTests.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ public void WritesErrorWhenUnableToBootstrap()
1616

1717
var error = sut.GetErrorText();
1818

19-
error.Should().StartWith("Unable to bootstrap EDOT .NET due to");
20-
error.Should().Contain(TestableAutoInstrumentationPlugin.ExceptionMessage);
19+
Assert.StartsWith("Unable to bootstrap EDOT .NET due to", error);
20+
Assert.Contains(TestableAutoInstrumentationPlugin.ExceptionMessage, error);
2121
}
2222

2323
private class TestableAutoInstrumentationPlugin : AutoInstrumentationPlugin

tests/Elastic.OpenTelemetry.Tests/Configuration/ElasticOpenTelemetryOptionsTests.cs

+49-50
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,22 @@ public void DefaultCtor_SetsExpectedDefaults_WhenNoEnvironmentVariablesAreConfig
2929
{ ELASTIC_OTEL_SKIP_OTLP_EXPORTER, null },
3030
});
3131

32-
sut.GlobalLogEnabled.Should().Be(false);
32+
Assert.False(sut.GlobalLogEnabled);
33+
3334
// these default to null because any other value would enable file logging
34-
sut.LogDirectory.Should().Be(sut.LogDirectoryDefault);
35-
sut.LogLevel.Should().Be(LogLevel.Warning);
35+
Assert.Equal(sut.LogDirectoryDefault, sut.LogDirectory);
36+
Assert.Equal(LogLevel.Warning, sut.LogLevel);
3637

37-
sut.SkipOtlpExporter.Should().Be(false);
38+
Assert.False(sut.SkipOtlpExporter);
3839

3940
var logger = new TestLogger(output);
4041

4142
sut.LogConfigSources(logger);
4243

43-
logger.Messages.Count.Should().Be(ExpectedLogsLength);
44+
Assert.Equal(ExpectedLogsLength, logger.Messages.Count);
45+
4446
foreach (var message in logger.Messages)
45-
message.Should().EndWith("from [Default]");
47+
Assert.EndsWith("from [Default]", message);
4648
}
4749

4850
[Fact]
@@ -58,18 +60,17 @@ public void DefaultCtor_LoadsConfigurationFromEnvironmentVariables()
5860
{ ELASTIC_OTEL_SKIP_OTLP_EXPORTER, "true" },
5961
});
6062

61-
sut.LogDirectory.Should().Be(fileLogDirectory);
62-
sut.LogLevel.Should().Be(ToLogLevel(fileLogLevel));
63-
sut.SkipOtlpExporter.Should().Be(true);
63+
Assert.Equal(fileLogDirectory, sut.LogDirectory);
64+
Assert.Equal(ToLogLevel(fileLogLevel), sut.LogLevel);
65+
Assert.True(sut.SkipOtlpExporter);
6466

6567
var logger = new TestLogger(output);
6668

6769
sut.LogConfigSources(logger);
6870

69-
logger.Messages.Should()
70-
.Contain(s => s.EndsWith("from [Environment]"))
71-
.And.Contain(s => s.EndsWith("from [Default]"))
72-
.And.NotContain(s => s.EndsWith("from [IConfiguration]"));
71+
Assert.Contains(logger.Messages, s => s.EndsWith("from [Environment]"));
72+
Assert.Contains(logger.Messages, s => s.EndsWith("from [Default]"));
73+
Assert.DoesNotContain(logger.Messages, s => s.EndsWith("from [IConfiguration]"));
7374
}
7475

7576
[Fact]
@@ -104,21 +105,21 @@ public void ConfigurationCtor_LoadsConfigurationFromIConfiguration()
104105

105106
var sut = new CompositeElasticOpenTelemetryOptions(config, new Hashtable());
106107

107-
sut.LogDirectory.Should().Be(@"C:\Temp");
108-
sut.LogLevel.Should().Be(ToLogLevel(fileLogLevel));
109-
sut.SkipOtlpExporter.Should().Be(true);
110-
sut.EventLogLevel.Should().Be(EventLevel.Warning);
111-
sut.LogLevel.Should().Be(LogLevel.Critical);
108+
Assert.Equal(@"C:\Temp", sut.LogDirectory);
109+
Assert.Equal(ToLogLevel(fileLogLevel), sut.LogLevel);
110+
Assert.True(sut.SkipOtlpExporter);
111+
Assert.Equal(EventLevel.Warning, sut.EventLogLevel);
112+
Assert.Equal(LogLevel.Critical, sut.LogLevel);
112113

113114
var logger = new TestLogger(output);
114115

115116
sut.LogConfigSources(logger);
116117

117-
logger.Messages.Count.Should().Be(ExpectedLogsLength);
118-
logger.Messages.Should()
119-
.Contain(s => s.EndsWith("from [IConfiguration]"))
120-
.And.Contain(s => s.EndsWith("from [Default]"))
121-
.And.NotContain(s => s.EndsWith("from [Environment]"));
118+
Assert.Equal(ExpectedLogsLength, logger.Messages.Count);
119+
120+
Assert.Contains(logger.Messages, s => s.EndsWith("from [IConfiguration]"));
121+
Assert.Contains(logger.Messages, s => s.EndsWith("from [Default]"));
122+
Assert.DoesNotContain(logger.Messages, s => s.EndsWith("from [Environment]"));
122123
}
123124

124125
[Fact]
@@ -151,20 +152,19 @@ public void ConfigurationCtor_LoadsConfigurationFromIConfiguration_AndFallsBackT
151152

152153
var sut = new CompositeElasticOpenTelemetryOptions(config, new Hashtable());
153154

154-
sut.LogDirectory.Should().Be(@"C:\Temp");
155-
sut.LogLevel.Should().Be(ToLogLevel(loggingSectionLogLevel));
156-
sut.SkipOtlpExporter.Should().Be(true);
157-
sut.LogLevel.Should().Be(LogLevel.Warning);
158-
sut.EventLogLevel.Should().Be(EventLevel.Warning);
155+
Assert.Equal(@"C:\Temp", sut.LogDirectory);
156+
Assert.Equal(ToLogLevel(loggingSectionLogLevel), sut.LogLevel);
157+
Assert.True(sut.SkipOtlpExporter);
158+
Assert.Equal(EventLevel.Warning, sut.EventLogLevel);
159+
Assert.Equal(LogLevel.Warning, sut.LogLevel);
159160

160161
var logger = new TestLogger(output);
161162

162163
sut.LogConfigSources(logger);
163164

164-
logger.Messages.Should()
165-
.Contain(s => s.EndsWith("from [IConfiguration]"))
166-
.And.Contain(s => s.EndsWith("from [Default]"))
167-
.And.NotContain(s => s.EndsWith("from [Environment]"));
165+
Assert.Contains(logger.Messages, s => s.EndsWith("from [IConfiguration]"));
166+
Assert.Contains(logger.Messages, s => s.EndsWith("from [Default]"));
167+
Assert.DoesNotContain(logger.Messages, s => s.EndsWith("from [Environment]"));
168168
}
169169

170170
[Fact]
@@ -196,19 +196,18 @@ public void ConfigurationCtor_LoadsConfigurationFromIConfiguration_AndFallsBackT
196196

197197
var sut = new CompositeElasticOpenTelemetryOptions(config, new Hashtable());
198198

199-
sut.LogDirectory.Should().Be(@"C:\Temp");
200-
sut.LogLevel.Should().Be(ToLogLevel(loggingSectionDefaultLogLevel));
201-
sut.SkipOtlpExporter.Should().Be(true);
202-
sut.EventLogLevel.Should().Be(EventLevel.Informational);
199+
Assert.Equal(@"C:\Temp", sut.LogDirectory);
200+
Assert.Equal(ToLogLevel(loggingSectionDefaultLogLevel), sut.LogLevel);
201+
Assert.True(sut.SkipOtlpExporter);
202+
Assert.Equal(EventLevel.Informational, sut.EventLogLevel);
203203

204204
var logger = new TestLogger(output);
205205

206206
sut.LogConfigSources(logger);
207207

208-
logger.Messages.Should()
209-
.Contain(s => s.EndsWith("from [IConfiguration]"))
210-
.And.Contain(s => s.EndsWith("from [Default]"))
211-
.And.NotContain(s => s.EndsWith("from [Environment]"));
208+
Assert.Contains(logger.Messages, s => s.EndsWith("from [IConfiguration]"));
209+
Assert.Contains(logger.Messages, s => s.EndsWith("from [Default]"));
210+
Assert.DoesNotContain(logger.Messages, s => s.EndsWith("from [Environment]"));
212211
}
213212

214213
[Fact]
@@ -241,9 +240,10 @@ public void EnvironmentVariables_TakePrecedenceOver_ConfigValues()
241240
{ ELASTIC_OTEL_SKIP_OTLP_EXPORTER, "true" },
242241
});
243242

244-
sut.LogDirectory.Should().Be(fileLogDirectory);
245-
sut.LogLevel.Should().Be(ToLogLevel(fileLogLevel));
246-
sut.SkipOtlpExporter.Should().Be(true);
243+
Assert.Equal(fileLogDirectory, sut.LogDirectory);
244+
Assert.Equal(ToLogLevel(fileLogLevel), sut.LogLevel);
245+
Assert.True(sut.SkipOtlpExporter);
246+
247247
}
248248

249249
[Fact]
@@ -264,17 +264,16 @@ public void InitializedProperties_TakePrecedenceOver_EnvironmentValues()
264264
SkipOtlpExporter = false,
265265
};
266266

267-
sut.LogDirectory.Should().Be(fileLogDirectory);
268-
sut.LogLevel.Should().Be(ToLogLevel(fileLogLevel));
269-
sut.SkipOtlpExporter.Should().Be(false);
267+
Assert.Equal(fileLogDirectory, sut.LogDirectory);
268+
Assert.Equal(ToLogLevel(fileLogLevel), sut.LogLevel);
269+
Assert.False(sut.SkipOtlpExporter);
270270

271271
var logger = new TestLogger(output);
272272

273273
sut.LogConfigSources(logger);
274274

275-
logger.Messages.Should()
276-
.Contain(s => s.EndsWith("from [Property]"))
277-
.And.Contain(s => s.EndsWith("from [Default]"))
278-
.And.NotContain(s => s.EndsWith("from [Environment]"));
275+
Assert.Contains(logger.Messages, s => s.EndsWith("from [Property]"));
276+
Assert.Contains(logger.Messages, s => s.EndsWith("from [Default]"));
277+
Assert.DoesNotContain(logger.Messages, s => s.EndsWith("from [Environment]"));
279278
}
280279
}

0 commit comments

Comments
 (0)