From fe6aa2a2dcaf6f45b44d927add5dc926485f4af0 Mon Sep 17 00:00:00 2001 From: Todd Baert Date: Fri, 26 Jul 2024 14:50:17 -0400 Subject: [PATCH] fixup: improve testing Signed-off-by: Todd Baert --- global.json | 2 +- .../OpenFeatureEvaluationContextTests.cs | 22 ++++++++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/global.json b/global.json index 9f8f3618..74eea28b 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { "rollForward": "latestFeature", - "version": "8.0.303" + "version": "8.0.302" } } diff --git a/test/OpenFeature.Tests/OpenFeatureEvaluationContextTests.cs b/test/OpenFeature.Tests/OpenFeatureEvaluationContextTests.cs index 896b56e2..2f1f8fc4 100644 --- a/test/OpenFeature.Tests/OpenFeatureEvaluationContextTests.cs +++ b/test/OpenFeature.Tests/OpenFeatureEvaluationContextTests.cs @@ -171,12 +171,28 @@ public void TryGetValue_WhenCalledWithExistingKey_ReturnsTrueAndExpectedValue() } [Fact] - public void GetValueOnTargetingKey_Equals_TargetingKey() + public void GetValueOnTargetingKeySetWithStructure_Equals_TargetingKey() { // Arrange var value = "my_targeting_key"; - var structure = new Structure(new Dictionary { { EvaluationContext.TargetingKeyIndex, new Value(value) } }); - var evaluationContext = new EvaluationContext(structure); + var evaluationContext = EvaluationContext.Builder().Set(EvaluationContext.TargetingKeyIndex, new Value(value)).Build(); + + // Act + var result = evaluationContext.TryGetValue(EvaluationContext.TargetingKeyIndex, out var actualValue); + var targetingKeyvalue = evaluationContext.TargetingKey; + + // Assert + Assert.True(result); + Assert.Equal(value, actualValue?.AsString); + Assert.Equal(value, targetingKeyvalue); + } + + [Fact] + public void GetValueOnTargetingKeySetWithTargetingKey_Equals_TargetingKey() + { + // Arrange + var value = "my_targeting_key"; + var evaluationContext = EvaluationContext.Builder().SetTargetingKey(value).Build(); // Act var result = evaluationContext.TryGetValue(EvaluationContext.TargetingKeyIndex, out var actualValue);