Skip to content

Commit f97434d

Browse files
committed
add tests for inherits form type ending in checks
1 parent 55bb386 commit f97434d

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

Tests/src/FluentValidation.AutoValidation.Shared/Extensions/TypeExtensionsTest.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using Microsoft.AspNetCore.Mvc;
23
using SharpGrip.FluentValidation.AutoValidation.Mvc.Attributes;
34
using SharpGrip.FluentValidation.AutoValidation.Shared.Extensions;
45
using Xunit;
@@ -46,11 +47,38 @@ public void Test_HasCustomAttribute()
4647
Assert.False(typeof(TestModelRecord).HasCustomAttribute<AutoValidationAttribute>());
4748
}
4849

50+
[Fact]
51+
public void Test_InheritsFromTypeWithNameEndingIn()
52+
{
53+
Assert.True(typeof(TestInherits1).InheritsFromTypeWithNameEndingIn("Controller"));
54+
Assert.True(typeof(TestInherits1).InheritsFromTypeWithNameEndingIn("controller"));
55+
Assert.True(typeof(TestInherits2).InheritsFromTypeWithNameEndingIn("Controller"));
56+
Assert.True(typeof(TestInherits2).InheritsFromTypeWithNameEndingIn("controller"));
57+
Assert.False(typeof(TestInherits3).InheritsFromTypeWithNameEndingIn("Controller"));
58+
Assert.False(typeof(TestInherits3).InheritsFromTypeWithNameEndingIn("controller"));
59+
Assert.False(typeof(TestInherits4).InheritsFromTypeWithNameEndingIn("Controller"));
60+
Assert.False(typeof(TestInherits4).InheritsFromTypeWithNameEndingIn("controller"));
61+
Assert.False(typeof(TestInherits5).InheritsFromTypeWithNameEndingIn("Controller"));
62+
Assert.False(typeof(TestInherits5).InheritsFromTypeWithNameEndingIn("controller"));
63+
}
64+
4965
[AutoValidation]
5066
private class TestModelClass;
5167

5268
[AutoValidateNever]
5369
private record TestModelRecord;
5470

5571
private enum TestModelEnum;
72+
73+
private class TestInherits1 : Controller;
74+
75+
private class TestInherits2 : CustomControllerBase;
76+
77+
private class TestInherits3 : ControllerBase;
78+
79+
private class TestInherits4 : ActionContext;
80+
81+
private class TestInherits5 : object;
82+
83+
private class CustomControllerBase : Controller;
5684
}

0 commit comments

Comments
 (0)