Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: Evaluation Context must only contain unique values #32

Merged
merged 1 commit into from
Aug 5, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions test/OpenFeature.Tests/OpenFeatureEvaluationContextTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public void Should_Merge_Two_Contexts()
}

[Fact]
[Specification("3.2.2", "Duplicate values being overwritten.")]
public void Should_Merge_TwoContexts_And_Override_Duplicates_With_RightHand_Context()
{
var context1 = new EvaluationContext();
Expand Down Expand Up @@ -77,5 +78,15 @@ public void EvaluationContext_Should_All_Types()
context.Get<DateTime>("key4").Should().Be(now);
context.Get<TestStructure>("key5").Should().Be(structure);
}

[Fact]
[Specification("3.1.4", "The evaluation context fields MUST have an unique key.")]
public void When_Duplicate_Key_Throw_Unique_Constraint()
{
var context = new EvaluationContext { { "key", "value" } };
var exception = Assert.Throws<ArgumentException>(() =>
context.Add("key", "overriden_value"));
exception.Message.Should().StartWith("An item with the same key has already been added.");
}
}
}