Add unit tests for various options and validators#329
Merged
Conversation
38c22fc to
70c8b42
Compare
There was a problem hiding this comment.
Pull request overview
Adds a broad set of new unit tests across Sharprompt’s core validation/options and internal utilities, plus a couple of small modernization/style tweaks (collection expressions) and a minor test refactor.
Changes:
- Added new test suites for validators, options validation, fluent extensions, registries, paginator behavior, optional/value helpers, and PromptCanceledException.
- Refactored
TextInputBufferTeststo reuse a helper for cursor-position setup and added a few additional buffer behavior tests. - Updated a couple of collection initializations to modern C# collection expression syntax.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| Sharprompt/Internal/OffscreenBuffer.cs | Uses collection expressions for initializing the output buffer. |
| Sharprompt.SourceGenerator/PromptBindableGenerator.cs | Modernizes Validators list initialization in generator metadata. |
| Sharprompt.Tests/ValidatorsTests.cs | Adds unit tests for Validators behaviors. |
| Sharprompt.Tests/ValidatorsExtensionsTests.cs | Adds tests for internal validators list merge helper. |
| Sharprompt.Tests/TypeHelperTests.cs | Adds tests for nullability detection and invariant conversions. |
| Sharprompt.Tests/TextInputBufferTests.cs | Refactors buffer setup and adds coverage for Clear, MoveToStart, MoveToEnd. |
| Sharprompt.Tests/PromptCanceledExceptionTests.cs | Adds constructor/property tests for PromptCanceledException. |
| Sharprompt.Tests/PaginatorTests.cs | Adds extensive paginator navigation/filtering/page-size tests. |
| Sharprompt.Tests/OptionsTests.cs | Adds EnsureOptions validation tests for option types. |
| Sharprompt.Tests/OptionalTests.cs | Adds tests for Optional<T> semantics and factory methods. |
| Sharprompt.Tests/ModelBinderRegistryTests.cs | Adds tests for registering and retrieving model binders. |
| Sharprompt.Tests/FluentExtensionsTests.cs | Adds tests for fluent options extension methods/chaining. |
| Sharprompt.Tests/EnumMetadataRegistryTests.cs | Adds tests for enum metadata registration and retrieval. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request primarily adds comprehensive unit tests for several core components in the codebase, including options validation, fluent API extensions, registries, paginator logic, and exception handling. Additionally, it includes a minor code style update for collection initialization. These changes aim to improve test coverage, ensure reliability, and modernize code style.
Unit tests for core components:
InputOptions,ConfirmOptions,PasswordOptions,SelectOptions,ListOptions,MultiSelectOptions) to verify correct validation logic and error handling in various scenarios.Optional<T>struct to verify its value semantics and creation logic.EnumMetadataRegistry,ModelBinderRegistry) to verify registration and retrieval behavior. [1] [2]PromptCanceledExceptionclass to ensure constructors and properties behave as expected.Code style improvements:
Validatorsproperty inPropertyMetadatato use the modern collection initializer syntax ([]instead ofnew()).Test refactoring:
MoveToPreviousWordtest inTextInputBufferTeststo use a helper method for buffer initialization, improving readability and maintainability.