Skip to content

Commit 9e49208

Browse files
committed
UsingStaticClass_WhenAddedDefaultDynamicLinqCustomTypeProvider_ShouldBeOk
1 parent 17bddd7 commit 9e49208

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

test/System.Linq.Dynamic.Core.Tests/SecurityTests.cs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
using System.IO;
22
using System.Linq.Dynamic.Core.Exceptions;
3-
using System.Net;
43
using System.Reflection;
54
using FluentAssertions;
65
using Xunit;
76

87
namespace System.Linq.Dynamic.Core.Tests;
98

10-
public partial class SecurityTests
9+
public class SecurityTests
1110
{
1211
class Message
1312
{
@@ -103,6 +102,29 @@ public void UsingStaticClass_ThrowsException(string selector)
103102
action.Should().Throw<ParseException>().WithMessage("Type 'System.Linq.Dynamic.Core.Tests.Helpers.Models.AppSettings' not found");
104103
}
105104

105+
[Theory]
106+
[InlineData("System.Linq.Dynamic.Core.Tests.Helpers.Models.AppSettings.SettingsProp[\"jwt\"]")]
107+
[InlineData("System.Linq.Dynamic.Core.Tests.Helpers.Models.AppSettings.SettingsField[\"jwt\"]")]
108+
[InlineData("c => System.Linq.Dynamic.Core.Tests.Helpers.Models.AppSettings.SettingsProp[\"jwt\"]")]
109+
[InlineData("c => System.Linq.Dynamic.Core.Tests.Helpers.Models.AppSettings.SettingsField[\"jwt\"]")]
110+
public void UsingStaticClass_WhenAddedDefaultDynamicLinqCustomTypeProvider_ShouldBeOk(string selector)
111+
{
112+
// Arrange
113+
var config = new ParsingConfig();
114+
config.UseDefaultDynamicLinqCustomTypeProvider([typeof(Helpers.Models.AppSettings)]);
115+
116+
var queryable = new[]
117+
{
118+
new Message("Alice", "Bob")
119+
}.AsQueryable();
120+
121+
// Act
122+
Action action = () => queryable.Select(config, selector);
123+
124+
// Assert
125+
action.Should().NotThrow();
126+
}
127+
106128
[Theory]
107129
[InlineData("System.Linq.Dynamic.Core.Tests.Helpers.Models.AppSettings2.SettingsProp[\"jwt\"]")]
108130
[InlineData("System.Linq.Dynamic.Core.Tests.Helpers.Models.AppSettings2.SettingsField[\"jwt\"]")]

0 commit comments

Comments
 (0)