-
Notifications
You must be signed in to change notification settings - Fork 13
Add caching property and method #16
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # V1.0.3 | ||
|
|
||
| ## New Property | ||
|
|
||
| | Property | Type | Default | Description | | ||
| |----------|------|---------|-------------| | ||
| | `CachingEnabled` | `bool` | `true` |When `true`, the generated table string is cached when the ToTable method is called. Cache will be cleared on any property change or method call. | | ||
|
|
||
| ## New Method | ||
|
|
||
| | Method | Description | | ||
| |--------|-------------| | ||
| | `ClearCache()` | Clears the cached generated table string. | |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -4,6 +4,46 @@ namespace ConsoleTable.Text.Tests; | |||||
|
|
||||||
| public class TableTests | ||||||
| { | ||||||
| [Theory] | ||||||
| [InlineData(true)] | ||||||
| [InlineData(false)] | ||||||
| public void PerformanceCheck(bool cacheEnabled) | ||||||
| { | ||||||
| var table = new Table | ||||||
| { | ||||||
| CachingEnabled = cacheEnabled, | ||||||
| HeaderTextAlignmentRight = true, | ||||||
| RowTextAlignmentRight = false, | ||||||
| Padding = 5 | ||||||
| }; | ||||||
|
|
||||||
| var columnCount = 100; | ||||||
| var headers = new List<string>(); | ||||||
| for (var columnPos = 1; columnPos <= columnCount; columnPos++) | ||||||
| { | ||||||
| headers.Add($"Header {columnPos}"); | ||||||
| } | ||||||
| table.Headers = headers.ToArray(); | ||||||
|
|
||||||
| var rows = new List<string[]>(); | ||||||
| for (var rowPos = 1; rowPos <= 100000; rowPos++) | ||||||
| { | ||||||
| var row = new string[columnCount]; | ||||||
| for (var columnPos = 1; columnPos <= columnCount; columnPos++) | ||||||
| { | ||||||
| row[columnPos - 1] = $"Row {rowPos} -> Column {columnPos}"; | ||||||
| } | ||||||
| rows.Add(row); | ||||||
| } | ||||||
| table.Rows = rows; | ||||||
|
|
||||||
| var tableResult1 = table.ToTable(); | ||||||
| Assert.NotEmpty(tableResult1); | ||||||
|
|
||||||
| var tableResult2 = table.ToTable(); | ||||||
| Assert.NotEmpty(tableResult2); | ||||||
| } | ||||||
|
|
||||||
| [Fact] | ||||||
| public void ToTable_EmptyTable_ReturnsEmptyString() | ||||||
| { | ||||||
|
|
@@ -555,6 +595,43 @@ public void AddRows_ClearsCache() | |||||
| Assert.Contains("NewRow", secondResult); | ||||||
| } | ||||||
|
|
||||||
| [Fact] | ||||||
| public void ClearCache() | ||||||
|
||||||
| public void ClearCache() | |
| public void ClearCache_AfterCaching_AllowsTableRegenerationWithSameContent() |
Copilot
AI
Dec 8, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test method name 'CachingEnabled' conflicts with the property being tested. Rename to follow the test naming pattern used elsewhere in the file, such as 'CachingEnabled_WithTrueOrFalse_GeneratesTableSuccessfully'.
| public void CachingEnabled(bool cachingEnabled) | |
| public void CachingEnabled_WithTrueOrFalse_ReturnsTableContainingRow(bool cachingEnabled) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The test method name 'PerformanceCheck' is unclear about what it's verifying. Consider renaming to something more specific like 'ToTable_WithDifferentCachingSettings_GeneratesTableSuccessfully' to clarify that this is a functional test rather than a performance benchmark.