Skip to content

Commit 669b1ca

Browse files
committed
Disable obsolete warnings in tests
1 parent 1e6b35b commit 669b1ca

File tree

7 files changed

+23
-11
lines changed

7 files changed

+23
-11
lines changed

Tests/Helpers/Testably.Abstractions.Tests.SourceGenerator/ClassGenerators/FileSystemClassGenerator.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public override void SkipIfLongRunningTestsShouldBeSkipped()
133133
#endif
134134
}}
135135
}}");
136-
if (!@class.Namespace.Equals("Testably.Abstractions.AccessControl.Tests", StringComparison.Ordinal))
136+
if (IncludeSimulatedTests(@class))
137137
{
138138
sourceBuilder.Append(@$"
139139
#if !NETFRAMEWORK
@@ -258,4 +258,10 @@ public override void SkipIfLongRunningTestsShouldBeSkipped()
258258
#endif");
259259
}
260260
}
261+
262+
private bool IncludeSimulatedTests(ClassModel @class)
263+
{
264+
return !@class.Namespace.Equals(
265+
"Testably.Abstractions.AccessControl.Tests", StringComparison.Ordinal);
266+
}
261267
}

Tests/Testably.Abstractions.Testing.Tests/FileSystem/PathMockTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ public sealed class PathMockTests
1414
public void GetTempFileName_WithCollisions_ShouldThrowIOException(
1515
SimulationMode simulationMode, int fixedRandomValue)
1616
{
17+
#pragma warning disable CS0618
1718
MockFileSystem fileSystem = new(i => i
1819
.SimulatingOperatingSystem(simulationMode)
1920
.UseRandomProvider(RandomProvider.Generate(
2021
intGenerator: new RandomProvider.Generator<int>(() => fixedRandomValue))));
22+
#pragma warning restore CS0618
2123
string result = fileSystem.Path.GetTempFileName();
2224

2325
Exception? exception = Record.Exception(() =>

Tests/Testably.Abstractions.Testing.Tests/Helpers/ExecuteExtensionsTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,10 @@ public void OnWindowsIf_ShouldExecuteDependingOnOperatingSystem(
192192

193193
#region Helpers
194194

195+
#pragma warning disable CS0618
195196
private static Execute FromType(SimulationMode type)
196197
=> new(new MockFileSystem(), type);
198+
#pragma warning restore CS0618
197199

198200
#endregion
199201
}

Tests/Testably.Abstractions.Testing.Tests/Helpers/ExecuteTests.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ public sealed class ExecuteTests
77
[Fact]
88
public void Constructor_ForLinux_ShouldInitializeAccordingly()
99
{
10+
#pragma warning disable CS0618
1011
Execute sut = new(new MockFileSystem(), SimulationMode.Linux);
12+
#pragma warning restore CS0618
1113

1214
sut.IsLinux.Should().BeTrue();
1315
sut.IsMac.Should().BeFalse();
@@ -19,7 +21,9 @@ public void Constructor_ForLinux_ShouldInitializeAccordingly()
1921
[Fact]
2022
public void Constructor_ForMacOS_ShouldInitializeAccordingly()
2123
{
24+
#pragma warning disable CS0618
2225
Execute sut = new(new MockFileSystem(), SimulationMode.MacOS);
26+
#pragma warning restore CS0618
2327

2428
sut.IsLinux.Should().BeFalse();
2529
sut.IsMac.Should().BeTrue();
@@ -31,7 +35,9 @@ public void Constructor_ForMacOS_ShouldInitializeAccordingly()
3135
[Fact]
3236
public void Constructor_ForWindows_ShouldInitializeAccordingly()
3337
{
38+
#pragma warning disable CS0618
3439
Execute sut = new(new MockFileSystem(), SimulationMode.Windows);
40+
#pragma warning restore CS0618
3541

3642
sut.IsLinux.Should().BeFalse();
3743
sut.IsMac.Should().BeFalse();

Tests/Testably.Abstractions.Testing.Tests/Helpers/PathHelperTests.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -120,15 +120,14 @@ public void
120120
.Which.Message.Should().Contain($"'{path}'");
121121
}
122122

123+
#if !NETFRAMEWORK
123124
[SkippableTheory]
124125
[InlineData('|')]
125126
[InlineData((char)1)]
126127
[InlineData((char)31)]
127128
public void ThrowCommonExceptionsIfPathIsInvalid_WithInvalidCharacters(
128129
char invalidChar)
129130
{
130-
Skip.If(Test.IsNetFramework);
131-
132131
MockFileSystem fileSystem = new(i => i
133132
.SimulatingOperatingSystem(SimulationMode.Windows));
134133
string path = invalidChar + "path";
@@ -137,15 +136,10 @@ public void ThrowCommonExceptionsIfPathIsInvalid_WithInvalidCharacters(
137136
{
138137
path.EnsureValidFormat(fileSystem);
139138
});
140-
141-
#if NETFRAMEWORK
142-
exception.Should().BeOfType<ArgumentException>()
143-
.Which.Message.Should().Contain("path");
144-
#else
145139
exception.Should().BeOfType<IOException>()
146140
.Which.Message.Should().Contain(path);
147-
#endif
148141
}
142+
#endif
149143

150144
[Fact]
151145
public void

Tests/Testably.Abstractions.Testing.Tests/MockFileSystemInitializationTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
using System.IO;
33
using System.Linq;
44
using Testably.Abstractions.Testing.Tests.TestHelpers;
5-
#if NET6_0_OR_GREATER
6-
#endif
75

86
namespace Testably.Abstractions.Testing.Tests;
97

@@ -93,7 +91,9 @@ public void SimulatingOperatingSystem_ValidOSPlatform_ShouldSetOperatingSystem(
9391
{
9492
MockFileSystem.Initialization sut = new();
9593

94+
#pragma warning disable CS0618
9695
MockFileSystem.Initialization result = sut.SimulatingOperatingSystem(simulationMode);
96+
#pragma warning restore CS0618
9797

9898
result.SimulationMode.Should().Be(simulationMode);
9999
sut.SimulationMode.Should().Be(simulationMode);

Tests/Testably.Abstractions.Testing.Tests/MockFileSystemTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,9 @@ public void FileSystemMock_ShouldNotSupportSimulatingOtherOperatingSystemsOnNetF
102102
{
103103
Exception? exception = Record.Exception(() =>
104104
{
105+
#pragma warning disable CS0618
105106
_ = new MockFileSystem(i => i.SimulatingOperatingSystem(simulationMode));
107+
#pragma warning restore CS0618
106108
});
107109

108110
exception.Should().BeOfType<NotSupportedException>()

0 commit comments

Comments
 (0)