{
using Configuration = System.Net.Test.Common.Configuration;
- public class SslStreamNetworkStreamTest : IDisposable
+ public class SslStreamNetworkStreamTest
{
- private readonly X509Certificate2 _serverCert;
- private readonly X509Certificate2Collection _serverChain;
+ private static readonly X509Certificate2 _serverCert;
+ private static readonly X509Certificate2Collection _serverChain;
- public SslStreamNetworkStreamTest()
+ static SslStreamNetworkStreamTest()
{
- (_serverCert, _serverChain) = TestHelper.GenerateCertificates("localhost", this.GetType().Name);
- }
-
- public void Dispose()
- {
- TestHelper.CleanupCertificates(this.GetType().Name);
+ TestHelper.CleanupCertificates(nameof(SslStreamNetworkStreamTest));
+ (_serverCert, _serverChain) = TestHelper.GenerateCertificates("localhost", nameof(SslStreamNetworkStreamTest));
}
[Fact]
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using System.Security.Cryptography.X509Certificates.Tests.Common;
+using System.Runtime.CompilerServices;
using System.Text;
namespace System.Net.Security.Tests
}
catch { };
}
- internal static (X509Certificate2 certificate, X509Certificate2Collection) GenerateCertificates(string targetName, string? testName = null)
+
+ internal static (X509Certificate2 certificate, X509Certificate2Collection) GenerateCertificates(string targetName, [CallerMemberName] string? testName = null)
{
if (PlatformDetection.IsWindows && testName != null)
{