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

Add ReadOnlySet<T> #103306

Merged
merged 3 commits into from
Jun 12, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Add test
  • Loading branch information
stephentoub committed Jun 12, 2024
commit 3bd9b14f4f94b249e502a0ca1a2b3623b311797c
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,21 @@ public void MembersDelegateToWrappedSet()
Assert.NotNull(set.GetEnumerator());
}

[Fact]
public void ChangesToUnderlyingSetReflected()
{
var set = new HashSet<int> { 1, 2, 3 };
var readOnlySet = new ReadOnlySet<int>(set);

set.Add(4);
Assert.Equal(4, readOnlySet.Count);
Assert.True(readOnlySet.Contains(4));

set.Remove(2);
Assert.Equal(3, readOnlySet.Count);
Assert.False(readOnlySet.Contains(2));
}

[Fact]
public void IsReadOnly_True()
{
Expand Down
Loading