11using System . Collections ;
22using System . Collections . Generic ;
33using System . Linq . Dynamic . Core . Tests . Helpers . Models ;
4+ using FluentAssertions ;
5+ using Newtonsoft . Json . Linq ;
46using Xunit ;
57
68namespace System . Linq . Dynamic . Core . Tests
@@ -103,6 +105,22 @@ public void SelectMany_Dynamic_IntoType()
103105 Assert . Equal ( queryNormal , queryDynamic ) ;
104106 }
105107
108+ [ Fact ]
109+ public void SelectMany_Dynamic_OverJArray_TResult ( )
110+ {
111+ // Arrange
112+ var array1 = JArray . Parse ( "[1,2,3]" ) ;
113+ var array2 = JArray . Parse ( "[4,5,6]" ) ;
114+
115+ // Act
116+ var expectedResult = new [ ] { array1 , array2 } . SelectMany ( it => it ) . ToArray ( ) ;
117+ var result = new [ ] { array1 , array2 } . AsQueryable ( ) . SelectMany ( "it" ) . ToDynamicArray < JToken > ( ) ;
118+
119+ // Assert
120+ result . Should ( ) . BeEquivalentTo ( expectedResult ) ;
121+ // result.Should().HaveCount(6).And.Subject.Select(j => j.Value).Should().ContainInOrder(new[] { 1, 2, 3, 4, 5, 6 });
122+ }
123+
106124 [ Fact ]
107125 public void SelectMany_Dynamic_OverArray_TResult ( )
108126 {
@@ -119,6 +137,21 @@ public void SelectMany_Dynamic_OverArray_TResult()
119137 Assert . Equal ( expectedResult , result ) ;
120138 }
121139
140+ [ Fact ]
141+ public void SelectMany_Dynamic_OverArray_Int ( )
142+ {
143+ var testList = new [ ]
144+ {
145+ new [ ] { 1 , 2 , 3 } ,
146+ new [ ] { 4 , 5 , 6 }
147+ } ;
148+
149+ var expectedResult = testList . SelectMany ( it => it ) . ToList ( ) ;
150+ var result = testList . AsQueryable ( ) . SelectMany < int > ( "it" ) . ToList ( ) ;
151+
152+ Assert . Equal ( expectedResult , result ) ;
153+ }
154+
122155 [ Fact ]
123156 public void SelectMany_Dynamic_OverArray_IntoType ( )
124157 {
0 commit comments