@@ -170,4 +170,70 @@ public void TestInterpolationWithNestedContextAttributes()
170170 var result = Eval ( "I can ingest over {{ ldctx.stats.power }} tokens per second!" , context , null ) ;
171171 Assert . Equal ( "I can ingest over 9000 tokens per second!" , result ) ;
172172 }
173+
174+ [ Fact ]
175+ public void TestInterpolationWithMultiKindContext ( )
176+ {
177+ var user = Context . Builder ( ContextKind . Default , "123" )
178+ . Set ( "cat_ownership" , LdValue . ObjectFrom ( new Dictionary < string , LdValue >
179+ {
180+ { "count" , LdValue . Of ( 12 ) }
181+ } ) ) . Build ( ) ;
182+
183+ var cat = Context . Builder ( ContextKind . Of ( "cat" ) , "456" )
184+ . Set ( "health" , LdValue . ObjectFrom ( new Dictionary < string , LdValue >
185+ {
186+ { "hunger" , LdValue . Of ( "off the charts" ) }
187+ } ) ) . Build ( ) ;
188+
189+ var context = Context . MultiBuilder ( ) . Add ( user ) . Add ( cat ) . Build ( ) ;
190+
191+ var nestedVars = Eval ( "As an owner of {{ ldctx.user.cat_ownership.count }} cats, I must report that my cat's hunger level is {{ ldctx.cat.health.hunger }}!" , context , null ) ;
192+ Assert . Equal ( "As an owner of 12 cats, I must report that my cat's hunger level is off the charts!" , nestedVars ) ;
193+
194+ var canonicalKeys = Eval ( "multi={{ ldctx.key }} user={{ ldctx.user.key }} cat={{ ldctx.cat.key }}" , context , null ) ;
195+ Assert . Equal ( "multi=cat:456:user:123 user=123 cat=456" , canonicalKeys ) ;
196+ }
197+
198+ [ Fact ]
199+ public void TestInterpolationMultiKindDoesNotHaveAnonymousAttribute ( )
200+ {
201+ var user = Context . Builder ( ContextKind . Default , "123" )
202+ . Set ( "cat_ownership" , LdValue . ObjectFrom ( new Dictionary < string , LdValue >
203+ {
204+ { "count" , LdValue . Of ( 12 ) }
205+ } ) ) . Build ( ) ;
206+
207+ var cat = Context . Builder ( ContextKind . Of ( "cat" ) , "456" )
208+ . Set ( "health" , LdValue . ObjectFrom ( new Dictionary < string , LdValue >
209+ {
210+ { "hunger" , LdValue . Of ( "off the charts" ) }
211+ } ) ) . Build ( ) ;
212+
213+ var context = Context . MultiBuilder ( ) . Add ( user ) . Add ( cat ) . Build ( ) ;
214+
215+ var result = Eval ( "anonymous=<{{ ldctx.anonymous }}>" , context , null ) ;
216+ Assert . Equal ( "anonymous=<>" , result ) ;
217+ }
218+
219+ [ Fact ]
220+ public void TestInterpolationMultiKindContextHasKindMulti ( )
221+ {
222+ var user = Context . Builder ( ContextKind . Default , "123" )
223+ . Set ( "cat_ownership" , LdValue . ObjectFrom ( new Dictionary < string , LdValue >
224+ {
225+ { "count" , LdValue . Of ( 12 ) }
226+ } ) ) . Build ( ) ;
227+
228+ var cat = Context . Builder ( ContextKind . Of ( "cat" ) , "456" )
229+ . Set ( "health" , LdValue . ObjectFrom ( new Dictionary < string , LdValue >
230+ {
231+ { "hunger" , LdValue . Of ( "off the charts" ) }
232+ } ) ) . Build ( ) ;
233+
234+ var context = Context . MultiBuilder ( ) . Add ( user ) . Add ( cat ) . Build ( ) ;
235+
236+ var result = Eval ( "kind={{ ldctx.kind }}" , context , null ) ;
237+ Assert . Equal ( "kind=multi" , result ) ;
238+ }
173239}
0 commit comments