Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,25 @@
using System.Reflection;
using Xunit;

#pragma warning disable IDE0079
#pragma warning disable S2094
#pragma warning disable S2544
#pragma warning disable S1186
#pragma warning disable S1144
#pragma warning disable S4144

namespace AutoMapper.Extensions.ExpressionMapping.UnitTests
{
public class TypeExtensionsTest
{
#region Has<TAttribute> Tests

#pragma warning disable IDE0079 // Remove unnecessary suppression - SonarQube rules (S*) are not recognized by the IDE
#pragma warning disable S1144 // Unused private types - test helper types referenced via typeof() and reflection
#pragma warning disable S2094 // Classes should not be empty - test helper types intentionally have no members
[AttributeUsage(AttributeTargets.Class)]
private class TestAttribute : Attribute { }

[Test]
private class ClassWithAttribute { }

private class ClassWithoutAttribute { }
#pragma warning restore S2094
#pragma warning restore S1144
#pragma warning restore IDE0079

[Fact]
public void Has_TypeWithAttribute_ReturnsTrue()
Expand Down Expand Up @@ -55,6 +54,10 @@ public void Has_TypeWithoutAttribute_ReturnsFalse()

#region GetDeclaredConstructors Tests

#pragma warning disable IDE0079 // Remove unnecessary suppression - SonarQube rules (S*) are not recognized by the IDE
#pragma warning disable S1144 // Unused private type - referenced via typeof() in tests
#pragma warning disable S1186 // Methods should not be empty - constructors intentionally have no body
#pragma warning disable S4144 // Methods should not have identical implementations - empty constructors with different signatures serve distinct test scenarios
private class ClassWithMultipleConstructors
{
public ClassWithMultipleConstructors() { }
Expand All @@ -65,6 +68,10 @@ public ClassWithMultipleConstructors(int value) { }
public ClassWithMultipleConstructors(string text, int value) { }
#pragma warning restore IDE0060 // Remove unused parameter
}
#pragma warning restore S4144
#pragma warning restore S1186
#pragma warning restore S1144
#pragma warning restore IDE0079

[Fact]
public void GetDeclaredConstructors_ReturnsAllConstructors()
Expand All @@ -83,13 +90,19 @@ public void GetDeclaredConstructors_ReturnsAllConstructors()

#region GetDeclaredMethod Tests

#pragma warning disable IDE0079 // Remove unnecessary suppression - SonarQube rules (S*) are not recognized by the IDE
#pragma warning disable S1144 // Unused private type - referenced via typeof() and reflection in tests
#pragma warning disable S1186 // Methods should not be empty - test helper methods intentionally have no body
private class ClassWithMethods
{
public void TestMethod() { }
#pragma warning disable IDE0060 // Remove unused parameter
public void AnotherMethod(int value) { }
#pragma warning restore IDE0060 // Remove unused parameter
}
#pragma warning restore S1186
#pragma warning restore S1144
#pragma warning restore IDE0079

[Fact]
public void GetDeclaredMethod_ExistingMethod_ReturnsMethod()
Expand Down Expand Up @@ -187,11 +200,15 @@ public void GetAllMethods_ReturnsAllRuntimeMethods()

#region GetDeclaredProperties Tests

#pragma warning disable IDE0079 // Remove unnecessary suppression - SonarQube rules (S*) are not recognized by the IDE
#pragma warning disable S1144 // Unused private type - referenced via typeof() in tests
private class ClassWithProperties
{
public int Property1 { get; set; }
public string Property2 { get; set; }
}
#pragma warning restore S1144
#pragma warning restore IDE0079

[Fact]
public void GetDeclaredProperties_ReturnsAllDeclaredProperties()
Expand All @@ -212,6 +229,10 @@ public void GetDeclaredProperties_ReturnsAllDeclaredProperties()

#region IsStatic Tests

#pragma warning disable IDE0079 // Remove unnecessary suppression - SonarQube rules (S*) are not recognized by the IDE
#pragma warning disable S1144 // Unused private type and members - accessed via GetField/GetProperty/GetMethod reflection in tests
#pragma warning disable S1186 // Methods should not be empty - test helper methods intentionally have no body
#pragma warning disable S4144 // Methods should not have identical implementations - StaticMethod and InstanceMethod intentionally mirror each other for static/instance comparison tests
private class ClassWithStaticMembers
{
public static readonly int StaticField = 0;
Expand All @@ -221,6 +242,10 @@ private class ClassWithStaticMembers
public static void StaticMethod() { }
public void InstanceMethod() { }
}
#pragma warning restore S4144
#pragma warning restore S1186
#pragma warning restore S1144
#pragma warning restore IDE0079

[Fact]
public void IsStatic_StaticField_ReturnsTrue()
Expand Down Expand Up @@ -356,7 +381,11 @@ public void IsStatic_MemberInfoAsStaticProperty_ReturnsTrue()

#region IsEnum Tests

#pragma warning disable IDE0079 // Remove unnecessary suppression - SonarQube rules (S*) are not recognized by the IDE
#pragma warning disable S1144 // Unused private type - referenced via typeof() in tests
private enum Values { Value1, Value2 }
#pragma warning restore S1144
#pragma warning restore IDE0079

[Fact]
public void IsEnum_EnumType_ReturnsTrue()
Expand Down Expand Up @@ -744,11 +773,3 @@ public void ReplaceItemType_MultipleGenericArguments_ReplacesAll()
#endregion
}
}


#pragma warning restore S2094
#pragma warning restore S2544
#pragma warning restore S1186
#pragma warning restore S1144
#pragma warning restore S4144
#pragma warning restore IDE0079