@@ -49,6 +49,53 @@ public void ReturnsDefaultConfigWhenGivenInvalidVariation()
49
49
Assert . Equal ( defaultConfig , tracker . Config ) ;
50
50
}
51
51
52
+ [ Fact ]
53
+ public void ConfigMethodCallsTrackWithCorrectParameters ( )
54
+ {
55
+ var mockClient = new Mock < ILaunchDarklyClient > ( ) ;
56
+ var context = Context . New ( ContextKind . Default , "user-key" ) ;
57
+ var configKey = "test-config-key" ;
58
+
59
+ mockClient . Setup ( c => c . JsonVariation (
60
+ It . IsAny < string > ( ) ,
61
+ It . IsAny < Context > ( ) ,
62
+ It . IsAny < LdValue > ( ) ) )
63
+ . Returns ( LdValue . ObjectFrom ( new Dictionary < string , LdValue >
64
+ {
65
+ [ "_ldMeta" ] = LdValue . ObjectFrom ( new Dictionary < string , LdValue >
66
+ {
67
+ [ "enabled" ] = LdValue . Of ( true ) ,
68
+ [ "variationKey" ] = LdValue . Of ( "test-variation" ) ,
69
+ [ "version" ] = LdValue . Of ( 1 )
70
+ } ) ,
71
+ [ "model" ] = LdValue . ObjectFrom ( new Dictionary < string , LdValue >
72
+ {
73
+ [ "name" ] = LdValue . Of ( "test-model" )
74
+ } ) ,
75
+ [ "provider" ] = LdValue . ObjectFrom ( new Dictionary < string , LdValue >
76
+ {
77
+ [ "name" ] = LdValue . Of ( "test-provider" )
78
+ } ) ,
79
+ [ "messages" ] = LdValue . ArrayOf ( )
80
+ } ) ) ;
81
+
82
+ var mockLogger = new Mock < ILogger > ( ) ;
83
+ mockClient . Setup ( x => x . GetLogger ( ) ) . Returns ( mockLogger . Object ) ;
84
+
85
+ var client = new LdAiClient ( mockClient . Object ) ;
86
+ var defaultConfig = LdAiConfig . New ( ) . Build ( ) ;
87
+
88
+ var tracker = client . Config ( configKey , context , defaultConfig ) ;
89
+
90
+ mockClient . Verify ( c => c . Track (
91
+ "$ld:ai:config:function:single" ,
92
+ context ,
93
+ LdValue . Of ( configKey ) ,
94
+ 1 ) , Times . Once ) ;
95
+
96
+ Assert . NotNull ( tracker ) ;
97
+ }
98
+
52
99
private const string MetaDisabledExplicitly = """
53
100
{
54
101
"_ldMeta": {"variationKey": "1", "enabled": false},
0 commit comments