File tree Expand file tree Collapse file tree 2 files changed +18
-3
lines changed
test/OpenFeature.SDK.Tests Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -20,14 +20,19 @@ public sealed class FeatureClient : IFeatureClient
2020 private readonly FeatureProvider _featureProvider ;
2121 private readonly List < Hook > _hooks = new List < Hook > ( ) ;
2222 private readonly ILogger _logger ;
23- private readonly EvaluationContext _evaluationContext ;
23+ private EvaluationContext _evaluationContext ;
2424
2525 /// <summary>
26- /// Gets the client <see cref="EvaluationContext"/>
26+ /// Gets the EvaluationContext of this client <see cref="EvaluationContext"/>
2727 /// </summary>
28- /// <returns></returns>
28+ /// <returns><see cref="EvaluationContext"/>of this client< /returns>
2929 public EvaluationContext GetContext ( ) => this . _evaluationContext ;
3030
31+ /// <summary>
32+ /// Sets the EvaluationContext of the client<see cref="EvaluationContext"/>
33+ /// </summary>
34+ public void SetContext ( EvaluationContext evaluationContext ) => this . _evaluationContext = evaluationContext ;
35+
3136 /// <summary>
3237 /// Initializes a new instance of the <see cref="FeatureClient"/> class.
3338 /// </summary>
Original file line number Diff line number Diff line change @@ -354,5 +354,15 @@ public void Should_Throw_ArgumentNullException_When_Provider_Is_Null()
354354 TestProvider provider = null ;
355355 Assert . Throws < ArgumentNullException > ( ( ) => new FeatureClient ( provider , "test" , "test" ) ) ;
356356 }
357+
358+ [ Fact ]
359+ public void Should_Get_And_Set_Context ( )
360+ {
361+ var KEY = "key" ;
362+ var VAL = 1 ;
363+ FeatureClient client = OpenFeature . Instance . GetClient ( ) ;
364+ client . SetContext ( new EvaluationContext ( ) . Add ( KEY , VAL ) ) ;
365+ Assert . Equal ( VAL , client . GetContext ( ) . GetValue ( KEY ) . AsInteger ( ) ) ;
366+ }
357367 }
358368}
You can’t perform that action at this time.
0 commit comments