Skip to content

Commit

Permalink
fix: sonar issue xUnit1040 (#445)
Browse files Browse the repository at this point in the history
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*
  • Loading branch information
vbreuss authored Jan 7, 2024
1 parent d31fe46 commit fd4d65b
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ public void

#region Helpers

public static TheoryData<Expression<Action<IDirectoryInfo>>, string?, bool> GetDirectoryInfoCallbacks(string? path)
public static TheoryData<Expression<Action<IDirectoryInfo>>, string, bool> GetDirectoryInfoCallbacks(string? path)
{
TheoryData<Expression<Action<IDirectoryInfo>>, string?, bool> theoryData = new();
TheoryData<Expression<Action<IDirectoryInfo>>, string, bool> theoryData = new();
foreach (var item in GetDirectoryInfoCallbackTestParameters(path!)
.Where(item => item.TestType.HasFlag(path.ToTestType())))
{
Expand All @@ -130,7 +130,7 @@ public void
return theoryData;
}

private static IEnumerable<(ExceptionTestHelper.TestTypes TestType, string? ParamName,
private static IEnumerable<(ExceptionTestHelper.TestTypes TestType, string ParamName,
Expression<Action<IDirectoryInfo>> Callback)>
GetDirectoryInfoCallbackTestParameters(string value)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ public void

#region Helpers

public static TheoryData<Expression<Action<IDirectoryInfoFactory>>, string?, bool> GetDirectoryInfoFactoryCallbacks(string? path)
public static TheoryData<Expression<Action<IDirectoryInfoFactory>>, string, bool> GetDirectoryInfoFactoryCallbacks(string? path)
{
TheoryData<Expression<Action<IDirectoryInfoFactory>>, string?, bool> theoryData = new();
TheoryData<Expression<Action<IDirectoryInfoFactory>>, string, bool> theoryData = new();
foreach (var item in GetDirectoryInfoFactoryCallbackTestParameters(path!)
.Where(item => item.TestType.HasFlag(path.ToTestType())))
{
Expand All @@ -108,7 +108,7 @@ public void
return theoryData;
}

private static IEnumerable<(ExceptionTestHelper.TestTypes TestType, string? ParamName,
private static IEnumerable<(ExceptionTestHelper.TestTypes TestType, string ParamName,
Expression<Action<IDirectoryInfoFactory>> Callback)>
GetDirectoryInfoFactoryCallbackTestParameters(string value)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ public void Operations_WhenValueIsNull_ShouldThrowArgumentNullException(

#region Helpers

public static TheoryData<Expression<Action<IDriveInfoFactory>>, string?, bool> GetDriveInfoFactoryCallbacks(string? path)
public static TheoryData<Expression<Action<IDriveInfoFactory>>, string, bool> GetDriveInfoFactoryCallbacks(string? path)
{
TheoryData<Expression<Action<IDriveInfoFactory>>, string?, bool> theoryData = new();
TheoryData<Expression<Action<IDriveInfoFactory>>, string, bool> theoryData = new();
foreach (var item in GetDriveInfoFactoryCallbackTestParameters(path!)
.Where(item => item.TestType.HasFlag(path.ToTestType())))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ public void

#region Helpers

public static TheoryData<Expression<Action<IFile>>, string?, bool> GetFileCallbacks(string? path)
public static TheoryData<Expression<Action<IFile>>, string, bool> GetFileCallbacks(string? path)
{
TheoryData<Expression<Action<IFile>>, string?, bool> theoryData = new();
TheoryData<Expression<Action<IFile>>, string, bool> theoryData = new();
foreach (var item in GetFileCallbackTestParameters(path!)
.Where(item => item.TestType.HasFlag(path.ToTestType())))
{
Expand All @@ -120,7 +120,7 @@ public void
return theoryData;
}

private static IEnumerable<(ExceptionTestHelper.TestTypes TestType, string? ParamName,
private static IEnumerable<(ExceptionTestHelper.TestTypes TestType, string ParamName,
Expression<Action<IFile>> Callback)>
GetFileCallbackTestParameters(string value)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ public void

#region Helpers

public static TheoryData<Expression<Action<IFileInfo>>, string?, bool> GetFileInfoCallbacks(string? path)
public static TheoryData<Expression<Action<IFileInfo>>, string, bool> GetFileInfoCallbacks(string? path)
{
TheoryData<Expression<Action<IFileInfo>>, string?, bool> theoryData = new();
TheoryData<Expression<Action<IFileInfo>>, string, bool> theoryData = new();
foreach (var item in GetFileInfoCallbackTestParameters(path!)
.Where(item => item.TestType.HasFlag(path.ToTestType())))
{
Expand All @@ -98,7 +98,7 @@ public void
return theoryData;
}

private static IEnumerable<(ExceptionTestHelper.TestTypes TestType, string? ParamName,
private static IEnumerable<(ExceptionTestHelper.TestTypes TestType, string ParamName,
Expression<Action<IFileInfo>> Callback)>
GetFileInfoCallbackTestParameters(string value)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ public void

#region Helpers

public static TheoryData<Expression<Action<IFileInfoFactory>>, string?, bool> GetFileInfoFactoryCallbacks(string? path)
public static TheoryData<Expression<Action<IFileInfoFactory>>, string, bool> GetFileInfoFactoryCallbacks(string? path)
{
TheoryData<Expression<Action<IFileInfoFactory>>, string?, bool> theoryData = new();
TheoryData<Expression<Action<IFileInfoFactory>>, string, bool> theoryData = new();
foreach (var item in GetFileInfoFactoryCallbackTestParameters(path!)
.Where(item => item.TestType.HasFlag(path.ToTestType())))
{
Expand All @@ -108,7 +108,7 @@ public void
return theoryData;
}

private static IEnumerable<(ExceptionTestHelper.TestTypes TestType, string? ParamName,
private static IEnumerable<(ExceptionTestHelper.TestTypes TestType, string ParamName,
Expression<Action<IFileInfoFactory>> Callback)>
GetFileInfoFactoryCallbackTestParameters(string value)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ public void

#region Helpers

public static TheoryData<Expression<Action<IFileStreamFactory>>, string?, bool> GetFileStreamFactoryCallbacks(string? path)
public static TheoryData<Expression<Action<IFileStreamFactory>>, string, bool> GetFileStreamFactoryCallbacks(string? path)
{
TheoryData<Expression<Action<IFileStreamFactory>>, string?, bool> theoryData = new();
TheoryData<Expression<Action<IFileStreamFactory>>, string, bool> theoryData = new();
foreach (var item in GetFileStreamFactoryCallbackTestParameters(path!)
.Where(item => item.TestType.HasFlag(path.ToTestType())))
{
Expand All @@ -121,7 +121,7 @@ public void
return theoryData;
}

private static IEnumerable<(ExceptionTestHelper.TestTypes TestType, string? ParamName,
private static IEnumerable<(ExceptionTestHelper.TestTypes TestType, string ParamName,
Expression<Action<IFileStreamFactory>> Callback)>
GetFileStreamFactoryCallbackTestParameters(string value)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ public void Operations_WhenValueIsNull_ShouldThrowArgumentNullException(

#region Helpers

public static TheoryData<Expression<Action<IFileSystemInfo>>, string?, bool> GetFileSystemInfoCallbacks(string? path)
public static TheoryData<Expression<Action<IFileSystemInfo>>, string, bool> GetFileSystemInfoCallbacks(string? path)
{
TheoryData<Expression<Action<IFileSystemInfo>>, string?, bool> theoryData = new();
TheoryData<Expression<Action<IFileSystemInfo>>, string, bool> theoryData = new();
foreach (var item in GetFileSystemInfoCallbackTestParameters(path!)
.Where(item => item.TestType.HasFlag(path.ToTestType())))
{
Expand All @@ -61,7 +61,7 @@ public void Operations_WhenValueIsNull_ShouldThrowArgumentNullException(
return theoryData;
}

private static IEnumerable<(ExceptionTestHelper.TestTypes TestType, string? ParamName,
private static IEnumerable<(ExceptionTestHelper.TestTypes TestType, string ParamName,
Expression<Action<IFileSystemInfo>> Callback)>
GetFileSystemInfoCallbackTestParameters(string value)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ public void

#region Helpers

public static TheoryData<Expression<Action<IFileSystemWatcherFactory>>, string?, bool> GetFileSystemWatcherFactoryCallbacks(string? path)
public static TheoryData<Expression<Action<IFileSystemWatcherFactory>>, string, bool> GetFileSystemWatcherFactoryCallbacks(string? path)
{
TheoryData<Expression<Action<IFileSystemWatcherFactory>>, string?, bool> theoryData = new();
TheoryData<Expression<Action<IFileSystemWatcherFactory>>, string, bool> theoryData = new();
foreach (var item in GetFileSystemWatcherFactoryCallbackTestParameters(path!)
.Where(item => item.TestType.HasFlag(path.ToTestType())))
{
Expand All @@ -111,7 +111,7 @@ public void
return theoryData;
}

private static IEnumerable<(ExceptionTestHelper.TestTypes TestType, string? ParamName,
private static IEnumerable<(ExceptionTestHelper.TestTypes TestType, string ParamName,
Expression<Action<IFileSystemWatcherFactory>> Callback)>
GetFileSystemWatcherFactoryCallbackTestParameters(string value)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ public void Operations_WhenValueIsNull_ShouldThrowArgumentNullException(

#region Helpers

public static TheoryData<Expression<Action<IPath>>, string?, bool> GetPathCallbacks(string? path)
public static TheoryData<Expression<Action<IPath>>, string, bool> GetPathCallbacks(string? path)
{
TheoryData<Expression<Action<IPath>>, string?, bool> theoryData = new();
TheoryData<Expression<Action<IPath>>, string, bool> theoryData = new();
foreach (var item in GetPathCallbackTestParameters(path!)
.Where(item => item.TestType.HasFlag(path.ToTestType())))
{
Expand All @@ -80,7 +80,7 @@ public void Operations_WhenValueIsNull_ShouldThrowArgumentNullException(
return theoryData;
}

private static IEnumerable<(ExceptionTestHelper.TestTypes TestType, string? ParamName,
private static IEnumerable<(ExceptionTestHelper.TestTypes TestType, string ParamName,
Expression<Action<IPath>> Callback)>
GetPathCallbackTestParameters(string value)
{
Expand Down

0 comments on commit fd4d65b

Please sign in to comment.