@@ -66,6 +66,54 @@ public void TestTupleModelBinder()
66
66
Assert . True ( result . BooleanCheck ) ;
67
67
}
68
68
69
+ [ Fact ]
70
+ public void TestNestedTupleModelBinder ( )
71
+ {
72
+ var type = typeof ( NestedTupleMemberTestData ) ;
73
+ var prop = type . GetProperty ( "Value" ) ;
74
+ var tupleType = prop . PropertyType ;
75
+ string body = @"
76
+ {
77
+ ""User"" : {
78
+ ""String"":""Test"",
79
+ ""Integer"":444,
80
+ ""Double"": 1.44,
81
+ ""Decimal"": 1.44
82
+ },
83
+ ""SomeData"" : ""Test String Root"",
84
+ ""NullCheck"": null,
85
+ ""BooleanCheck"": true,
86
+ ""ComplexNullCheck"":null,
87
+ ""IntParam6"": 6,
88
+ ""IntParam7"": 7,
89
+ ""IntParam8"": 8,
90
+ ""IntParam9"": 9,
91
+ }" ;
92
+
93
+ int parameterIndex = 0 ;
94
+ var jobj = JObject . Parse ( body ) ;
95
+ var tupleElementNames = ( TupleElementNamesAttribute ) prop . GetCustomAttributes ( typeof ( TupleElementNamesAttribute ) , true ) [ 0 ] ;
96
+
97
+ var result =
98
+ ( ( TestUserClass User , string SomeData , string NullCheck , bool BooleanCheck , TestUserClass ComplexNullCheck , int IntParam6 , int IntParam7 , int IntParam8 , int IntParam9 ) )
99
+ TupleModelBinder . ParseTupleFromModelAttributes ( jobj , tupleElementNames . TransformNames , tupleType , ref parameterIndex ) ;
100
+
101
+ Assert . NotNull ( result . User ) ;
102
+ Assert . Equal ( "Test" , result . User . String ) ;
103
+ Assert . Equal ( 444 , result . User . Integer ) ;
104
+ Assert . Equal ( 1.44d , result . User . Double ) ;
105
+ Assert . Equal ( 1.44m , result . User . Decimal ) ;
106
+
107
+ Assert . Equal ( "Test String Root" , result . SomeData ) ;
108
+ Assert . Null ( result . NullCheck ) ;
109
+ Assert . Null ( result . ComplexNullCheck ) ;
110
+ Assert . True ( result . BooleanCheck ) ;
111
+ Assert . Equal ( 6 , result . IntParam6 ) ;
112
+ Assert . Equal ( 7 , result . IntParam7 ) ;
113
+ Assert . Equal ( 8 , result . IntParam8 ) ;
114
+ Assert . Equal ( 9 , result . IntParam9 ) ;
115
+ }
116
+
69
117
[ Fact ]
70
118
public void TestNullHandling ( )
71
119
{
@@ -146,6 +194,11 @@ public class TupleMemberTestData
146
194
public ( TestUserClass User , string SomeData , string NullCheck , bool BooleanCheck , TestUserClass ComplexNullCheck ) Value { get ; set ; }
147
195
}
148
196
197
+ public class NestedTupleMemberTestData
198
+ {
199
+ public ( TestUserClass User , string SomeData , string NullCheck , bool BooleanCheck , TestUserClass ComplexNullCheck , int IntParam6 , int IntParam7 , int IntParam8 , int IntParam9 ) Value { get ; set ; }
200
+ }
201
+
149
202
public class NullMemberTestData
150
203
{
151
204
public ( string SomeData , string SomeNullData , string NullCheck , bool BooleanNullCheck , TestUserClass ComplexNullCheck ) Value { get ; set ; }
0 commit comments