Skip to content

Commit fd4d65b

Browse files
authored
fix: sonar issue xUnit1040 (#445)
Fix [xUnit1040](https://xunit.net/xunit.analyzers/rules/xUnit1040) The type argument to TheoryData is nullable, while the type of the corresponding test method parameter is not. *This was introduced in #443*
1 parent d31fe46 commit fd4d65b

File tree

10 files changed

+29
-29
lines changed

10 files changed

+29
-29
lines changed

Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/ExceptionTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,9 @@ public void
116116

117117
#region Helpers
118118

119-
public static TheoryData<Expression<Action<IDirectoryInfo>>, string?, bool> GetDirectoryInfoCallbacks(string? path)
119+
public static TheoryData<Expression<Action<IDirectoryInfo>>, string, bool> GetDirectoryInfoCallbacks(string? path)
120120
{
121-
TheoryData<Expression<Action<IDirectoryInfo>>, string?, bool> theoryData = new();
121+
TheoryData<Expression<Action<IDirectoryInfo>>, string, bool> theoryData = new();
122122
foreach (var item in GetDirectoryInfoCallbackTestParameters(path!)
123123
.Where(item => item.TestType.HasFlag(path.ToTestType())))
124124
{
@@ -130,7 +130,7 @@ public void
130130
return theoryData;
131131
}
132132

133-
private static IEnumerable<(ExceptionTestHelper.TestTypes TestType, string? ParamName,
133+
private static IEnumerable<(ExceptionTestHelper.TestTypes TestType, string ParamName,
134134
Expression<Action<IDirectoryInfo>> Callback)>
135135
GetDirectoryInfoCallbackTestParameters(string value)
136136
{

Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfoFactory/ExceptionTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ public void
9494

9595
#region Helpers
9696

97-
public static TheoryData<Expression<Action<IDirectoryInfoFactory>>, string?, bool> GetDirectoryInfoFactoryCallbacks(string? path)
97+
public static TheoryData<Expression<Action<IDirectoryInfoFactory>>, string, bool> GetDirectoryInfoFactoryCallbacks(string? path)
9898
{
99-
TheoryData<Expression<Action<IDirectoryInfoFactory>>, string?, bool> theoryData = new();
99+
TheoryData<Expression<Action<IDirectoryInfoFactory>>, string, bool> theoryData = new();
100100
foreach (var item in GetDirectoryInfoFactoryCallbackTestParameters(path!)
101101
.Where(item => item.TestType.HasFlag(path.ToTestType())))
102102
{
@@ -108,7 +108,7 @@ public void
108108
return theoryData;
109109
}
110110

111-
private static IEnumerable<(ExceptionTestHelper.TestTypes TestType, string? ParamName,
111+
private static IEnumerable<(ExceptionTestHelper.TestTypes TestType, string ParamName,
112112
Expression<Action<IDirectoryInfoFactory>> Callback)>
113113
GetDirectoryInfoFactoryCallbackTestParameters(string value)
114114
{

Tests/Testably.Abstractions.Tests/FileSystem/DriveInfoFactory/ExceptionTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ public void Operations_WhenValueIsNull_ShouldThrowArgumentNullException(
6363

6464
#region Helpers
6565

66-
public static TheoryData<Expression<Action<IDriveInfoFactory>>, string?, bool> GetDriveInfoFactoryCallbacks(string? path)
66+
public static TheoryData<Expression<Action<IDriveInfoFactory>>, string, bool> GetDriveInfoFactoryCallbacks(string? path)
6767
{
68-
TheoryData<Expression<Action<IDriveInfoFactory>>, string?, bool> theoryData = new();
68+
TheoryData<Expression<Action<IDriveInfoFactory>>, string, bool> theoryData = new();
6969
foreach (var item in GetDriveInfoFactoryCallbackTestParameters(path!)
7070
.Where(item => item.TestType.HasFlag(path.ToTestType())))
7171
{

Tests/Testably.Abstractions.Tests/FileSystem/File/ExceptionTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,9 @@ public void
106106

107107
#region Helpers
108108

109-
public static TheoryData<Expression<Action<IFile>>, string?, bool> GetFileCallbacks(string? path)
109+
public static TheoryData<Expression<Action<IFile>>, string, bool> GetFileCallbacks(string? path)
110110
{
111-
TheoryData<Expression<Action<IFile>>, string?, bool> theoryData = new();
111+
TheoryData<Expression<Action<IFile>>, string, bool> theoryData = new();
112112
foreach (var item in GetFileCallbackTestParameters(path!)
113113
.Where(item => item.TestType.HasFlag(path.ToTestType())))
114114
{
@@ -120,7 +120,7 @@ public void
120120
return theoryData;
121121
}
122122

123-
private static IEnumerable<(ExceptionTestHelper.TestTypes TestType, string? ParamName,
123+
private static IEnumerable<(ExceptionTestHelper.TestTypes TestType, string ParamName,
124124
Expression<Action<IFile>> Callback)>
125125
GetFileCallbackTestParameters(string value)
126126
{

Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/ExceptionTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ public void
8484

8585
#region Helpers
8686

87-
public static TheoryData<Expression<Action<IFileInfo>>, string?, bool> GetFileInfoCallbacks(string? path)
87+
public static TheoryData<Expression<Action<IFileInfo>>, string, bool> GetFileInfoCallbacks(string? path)
8888
{
89-
TheoryData<Expression<Action<IFileInfo>>, string?, bool> theoryData = new();
89+
TheoryData<Expression<Action<IFileInfo>>, string, bool> theoryData = new();
9090
foreach (var item in GetFileInfoCallbackTestParameters(path!)
9191
.Where(item => item.TestType.HasFlag(path.ToTestType())))
9292
{
@@ -98,7 +98,7 @@ public void
9898
return theoryData;
9999
}
100100

101-
private static IEnumerable<(ExceptionTestHelper.TestTypes TestType, string? ParamName,
101+
private static IEnumerable<(ExceptionTestHelper.TestTypes TestType, string ParamName,
102102
Expression<Action<IFileInfo>> Callback)>
103103
GetFileInfoCallbackTestParameters(string value)
104104
{

Tests/Testably.Abstractions.Tests/FileSystem/FileInfoFactory/ExceptionTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ public void
9494

9595
#region Helpers
9696

97-
public static TheoryData<Expression<Action<IFileInfoFactory>>, string?, bool> GetFileInfoFactoryCallbacks(string? path)
97+
public static TheoryData<Expression<Action<IFileInfoFactory>>, string, bool> GetFileInfoFactoryCallbacks(string? path)
9898
{
99-
TheoryData<Expression<Action<IFileInfoFactory>>, string?, bool> theoryData = new();
99+
TheoryData<Expression<Action<IFileInfoFactory>>, string, bool> theoryData = new();
100100
foreach (var item in GetFileInfoFactoryCallbackTestParameters(path!)
101101
.Where(item => item.TestType.HasFlag(path.ToTestType())))
102102
{
@@ -108,7 +108,7 @@ public void
108108
return theoryData;
109109
}
110110

111-
private static IEnumerable<(ExceptionTestHelper.TestTypes TestType, string? ParamName,
111+
private static IEnumerable<(ExceptionTestHelper.TestTypes TestType, string ParamName,
112112
Expression<Action<IFileInfoFactory>> Callback)>
113113
GetFileInfoFactoryCallbackTestParameters(string value)
114114
{

Tests/Testably.Abstractions.Tests/FileSystem/FileStreamFactory/ExceptionTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ public void
107107

108108
#region Helpers
109109

110-
public static TheoryData<Expression<Action<IFileStreamFactory>>, string?, bool> GetFileStreamFactoryCallbacks(string? path)
110+
public static TheoryData<Expression<Action<IFileStreamFactory>>, string, bool> GetFileStreamFactoryCallbacks(string? path)
111111
{
112-
TheoryData<Expression<Action<IFileStreamFactory>>, string?, bool> theoryData = new();
112+
TheoryData<Expression<Action<IFileStreamFactory>>, string, bool> theoryData = new();
113113
foreach (var item in GetFileStreamFactoryCallbackTestParameters(path!)
114114
.Where(item => item.TestType.HasFlag(path.ToTestType())))
115115
{
@@ -121,7 +121,7 @@ public void
121121
return theoryData;
122122
}
123123

124-
private static IEnumerable<(ExceptionTestHelper.TestTypes TestType, string? ParamName,
124+
private static IEnumerable<(ExceptionTestHelper.TestTypes TestType, string ParamName,
125125
Expression<Action<IFileStreamFactory>> Callback)>
126126
GetFileStreamFactoryCallbackTestParameters(string value)
127127
{

Tests/Testably.Abstractions.Tests/FileSystem/FileSystemInfo/ExceptionTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ public void Operations_WhenValueIsNull_ShouldThrowArgumentNullException(
4747

4848
#region Helpers
4949

50-
public static TheoryData<Expression<Action<IFileSystemInfo>>, string?, bool> GetFileSystemInfoCallbacks(string? path)
50+
public static TheoryData<Expression<Action<IFileSystemInfo>>, string, bool> GetFileSystemInfoCallbacks(string? path)
5151
{
52-
TheoryData<Expression<Action<IFileSystemInfo>>, string?, bool> theoryData = new();
52+
TheoryData<Expression<Action<IFileSystemInfo>>, string, bool> theoryData = new();
5353
foreach (var item in GetFileSystemInfoCallbackTestParameters(path!)
5454
.Where(item => item.TestType.HasFlag(path.ToTestType())))
5555
{
@@ -61,7 +61,7 @@ public void Operations_WhenValueIsNull_ShouldThrowArgumentNullException(
6161
return theoryData;
6262
}
6363

64-
private static IEnumerable<(ExceptionTestHelper.TestTypes TestType, string? ParamName,
64+
private static IEnumerable<(ExceptionTestHelper.TestTypes TestType, string ParamName,
6565
Expression<Action<IFileSystemInfo>> Callback)>
6666
GetFileSystemInfoCallbackTestParameters(string value)
6767
{

Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcherFactory/ExceptionTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,9 @@ public void
9797

9898
#region Helpers
9999

100-
public static TheoryData<Expression<Action<IFileSystemWatcherFactory>>, string?, bool> GetFileSystemWatcherFactoryCallbacks(string? path)
100+
public static TheoryData<Expression<Action<IFileSystemWatcherFactory>>, string, bool> GetFileSystemWatcherFactoryCallbacks(string? path)
101101
{
102-
TheoryData<Expression<Action<IFileSystemWatcherFactory>>, string?, bool> theoryData = new();
102+
TheoryData<Expression<Action<IFileSystemWatcherFactory>>, string, bool> theoryData = new();
103103
foreach (var item in GetFileSystemWatcherFactoryCallbackTestParameters(path!)
104104
.Where(item => item.TestType.HasFlag(path.ToTestType())))
105105
{
@@ -111,7 +111,7 @@ public void
111111
return theoryData;
112112
}
113113

114-
private static IEnumerable<(ExceptionTestHelper.TestTypes TestType, string? ParamName,
114+
private static IEnumerable<(ExceptionTestHelper.TestTypes TestType, string ParamName,
115115
Expression<Action<IFileSystemWatcherFactory>> Callback)>
116116
GetFileSystemWatcherFactoryCallbackTestParameters(string value)
117117
{

Tests/Testably.Abstractions.Tests/FileSystem/Path/ExceptionTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ public void Operations_WhenValueIsNull_ShouldThrowArgumentNullException(
6666

6767
#region Helpers
6868

69-
public static TheoryData<Expression<Action<IPath>>, string?, bool> GetPathCallbacks(string? path)
69+
public static TheoryData<Expression<Action<IPath>>, string, bool> GetPathCallbacks(string? path)
7070
{
71-
TheoryData<Expression<Action<IPath>>, string?, bool> theoryData = new();
71+
TheoryData<Expression<Action<IPath>>, string, bool> theoryData = new();
7272
foreach (var item in GetPathCallbackTestParameters(path!)
7373
.Where(item => item.TestType.HasFlag(path.ToTestType())))
7474
{
@@ -80,7 +80,7 @@ public void Operations_WhenValueIsNull_ShouldThrowArgumentNullException(
8080
return theoryData;
8181
}
8282

83-
private static IEnumerable<(ExceptionTestHelper.TestTypes TestType, string? ParamName,
83+
private static IEnumerable<(ExceptionTestHelper.TestTypes TestType, string ParamName,
8484
Expression<Action<IPath>> Callback)>
8585
GetPathCallbackTestParameters(string value)
8686
{

0 commit comments

Comments
 (0)