Skip to content

Commit

Permalink
Merge pull request #54 from GrahameGW/main
Browse files Browse the repository at this point in the history
Expose Clear function on EntityTable
  • Loading branch information
jolexxa authored Oct 28, 2024
2 parents 6bbfbc4 + 51072be commit 762b992
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Chickensoft.Collections.Tests/src/EntityTableTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,20 @@ public void StoresValues() {
table.Get<string>("a").ShouldBeNull();
table.Get<object>("b").ShouldNotBeNull();
}

[Fact]
public void Clears() {
var table = new EntityTable();

table.Set("a", "one");
table.Set("b", new object());

table.Get<string>("a").ShouldBe("one");
table.Get<object>("b").ShouldNotBeNull();

table.Clear();

table.Get<string>("a").ShouldBeNull();
table.Get<object>("b").ShouldBeNull();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ public void Remove(TId? id) {
_entities.TryRemove(id, out _);
}

/// <summary>
/// Clears (but does not dispose) all entities from the table.
/// </summary>
public void Clear() => _entities.Clear();

/// <summary>
/// Retrieve an entity from the table.
/// </summary>
Expand Down

0 comments on commit 762b992

Please sign in to comment.