Skip to content

Commit

Permalink
fixup: improve testing
Browse files Browse the repository at this point in the history
Signed-off-by: Todd Baert <[email protected]>
  • Loading branch information
toddbaert committed Jul 26, 2024
1 parent 90e9633 commit d5f1e44
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions test/OpenFeature.Tests/OpenFeatureEvaluationContextTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, Value> { { 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);
Expand Down

0 comments on commit d5f1e44

Please sign in to comment.