Skip to content

Commit

Permalink
Replaced the context.
Browse files Browse the repository at this point in the history
Signed-off-by: André Silva <[email protected]>
  • Loading branch information
askpt committed Jan 2, 2025
1 parent 7a60997 commit 1769be8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,17 @@ public void SetTransactionContext_SetsAndGetsContextCorrectly()
{
// Arrange
var propagator = new AsyncLocalTransactionContextPropagator();
var evaluationContext = EvaluationContext.Empty;
var evaluationContext = EvaluationContext.Builder()
.Set("initial", "yes")
.Build();

// Act
propagator.SetTransactionContext(evaluationContext);
var context = propagator.GetTransactionContext();

// Assert
Assert.Equal(evaluationContext, context);
Assert.Equal(evaluationContext.GetValue("initial"), context.GetValue("initial"));
}

[Fact]
Expand Down
5 changes: 4 additions & 1 deletion test/OpenFeature.Tests/OpenFeatureTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,9 @@ public void SetTransactionContext_ShouldSetTransactionContext_WhenValidEvaluatio
{
// Arrange
var api = Api.Instance;
var evaluationContext = EvaluationContext.Empty;
var evaluationContext = EvaluationContext.Builder()
.Set("initial", "yes")
.Build();
var mockPropagator = Substitute.For<ITransactionContextPropagator>();
mockPropagator.GetTransactionContext().Returns(evaluationContext);
api.SetTransactionContextPropagator(mockPropagator);
Expand All @@ -298,6 +300,7 @@ public void SetTransactionContext_ShouldSetTransactionContext_WhenValidEvaluatio
// Assert
mockPropagator.Received().SetTransactionContext(evaluationContext);
Assert.Equal(evaluationContext, result);
Assert.Equal(evaluationContext.GetValue("initial"), result.GetValue("initial"));
}

[Fact]
Expand Down

0 comments on commit 1769be8

Please sign in to comment.