-
-
Notifications
You must be signed in to change notification settings - Fork 0
Improved testing #76
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
Draft
IeuanWalker
wants to merge
50
commits into
master
Choose a base branch
from
Testing
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Improved testing #76
Conversation
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
Added EndpointRequestTypeMapperTests covering mapping and resolution logic for endpoint request types, including various scenarios (no data source, filtering, versioned routes). Refactored IeuanWalker.MinimalApi.Endpoints.Tests.csproj to consolidate Shouldly and NSubstitute package references into the main ItemGroup for better organization.
Switched from FormatterServices.GetUninitializedObject to RuntimeHelpers.GetUninitializedObject for creating uninitialized test instances, updating using directives accordingly. This avoids the use of obsolete APIs and modernizes the test code.
Added OpenApiConstantsTests to cover SchemaConstants methods: IsSystemType, IsNullableType, IsCollectionType, IsDictionaryType, and ArraySuffix constant. Tests use xUnit theories to validate various input scenarios and expected results.
Introduce OpenApiPathMatcherTests to cover various path matching scenarios, including case insensitivity, parameter normalization, version placeholders, and mismatch cases. These tests improve confidence in the correctness and robustness of the PathsMatch method.
Introduces OpenApiSchemaHelperTests with comprehensive coverage of schema handling, including primitives, arrays, generics, nullable types, enum references, and schema enrichment. Ensures correct behavior of OpenApiSchemaHelper methods.
Introduce SchemaTypeResolverTests to validate type resolution, enum handling (including nullable enums), assembly filtering, loadable type retrieval, and caching behavior. Ensures correct handling of system, custom, and invalid types.
Introduce PropertyValidationBuilderTests to verify rule building, append flag handling, operation management, and argument validation. Tests cover exception handling and ensure correct logic for Length, MinLength, MaxLength, Pattern, and Between methods.
Introduce ValidationConfigurationBuilderTests to verify rule collection, operation tracking, and property description behavior for simple, nested, and array properties. Tests ensure correct rule building and configuration overrides.
Introduced ValidationRuleTests covering RequiredRule, StringLengthRule, PatternRule, EmailRule, UrlRule, RangeRule, CustomRule, DescriptionRule, and EnumRule. Tests verify property assignment, default error messages, and exception handling for invalid arguments and constructor parameters.
Introduce ValidationRuleOperationTests to cover AlterOperation, RemoveOperation, and RemoveAllOperation behaviors. Tests ensure correct rule modification, removal, clearing, and exception handling for invalid operations or missing targets.
Added EnumSchemaTransformerTests to cover cases with no schemas, missing schema types, and enrichment of schemas with enum metadata. Includes a local enum for testing.
Added NullableSchemaReorderTransformerTests to verify correct reordering of nullable schemas in oneOf scenarios. Tests cover cases with no schemas, null type schemas, and nullable extension markers. Included necessary using directives and assertions for validation.
Comprehensive tests for TypeDocumentTransformer covering schema inlining, enum handling, collection/dictionary removal, and OpenAPI edge cases. Also fixed FixInlineSchemaType to check IFormFileCollection before IFormFile to ensure correct schema typing.
Comprehensive tests cover schema removal logic, including handling of null/empty components, referenced/unreferenced schemas, nested and composed schemas, headers, inline and circular references, and cancellation support. Uses Shouldly for assertions and includes helpers for mock OpenAPI documents and contexts.
Introduce ValidationDocumentTransformerTests covering constructor defaults, property mutability, interface implementation, and extensive TransformAsync scenarios. Tests ensure robustness against various OpenApiDocument structures, configuration options, and edge cases. No production code changes; improves test coverage and reliability.
Replaced all tests in ValidationDocumentTransformerTests.cs to focus on unit testing the CreateInlineSchemaWithAllValidation method. The new tests cover a broad range of validation rule scenarios (required, length, pattern, email, URL, range, description, custom, enum, nullable, array, multiple rules, extension and format preservation, and append rules behavior). Removed previous integration-style tests for TransformAsync. Added helper methods and enums for clarity and maintainability.
Added comprehensive unit tests for SecuritySchemeTransformer covering all supported authentication schemes, options, and edge cases. Also performed minor code cleanups in other test files, including exception handling, removal of unused variables, and improved parameter naming.
Relocated the InternalsVisibleTo attribute from InternalsVisibleTo.cs to IeuanWalker.MinimalApi.Endpoints.csproj, allowing test project access to internal members via the project file instead of a source file. Removed the now-unnecessary InternalsVisibleTo.cs.
Refactored FluentValidationExtensionsTests to improve clarity and structure of IsInEnum tests. Added explicit Arrange/Act/Assert sections, enhanced assertions for exception parameter names and error messages, and replaced condensed tests with more descriptive cases for non-enum types, valid/invalid values, and nullable scenarios.
Removed unit tests that used reflection to verify internal transformer state in OpenApiOptions. Also deleted related helper methods. Tests now only assert that extension methods return the same instance, focusing on public API behavior rather than internal implementation details.
Reformatted TestModel object initialization in both test methods to use multi-line syntax for improved readability. Also replaced "" with string.Empty for Name in the validation failure test. No functional changes were made.
Refactored test helper classes and context creation for clarity and maintainability. Moved helper classes to the end of the file, replaced reflection-based context setup with object initializers, and used method group conversions for MethodInfo retrieval. Cleaned up unused usings and improved code idiomatic usage without changing test logic.
Updated OpenApiConstantsTests to explicitly follow the Arrange-Act-Assert structure in all test methods. Each test now assigns method results to variables before assertions, improving readability and consistency. The ArraySuffix constant test was also refactored accordingly.
Refactored OpenApiPathMatcherTests to use Shouldly's ShouldBe and ShouldBeFalse assertions instead of xUnit's Assert methods. Added comments to clearly separate Arrange, Act, and Assert phases in each test for better readability and maintainability.
Refactored OpenApiSchemaHelperTests to explicitly separate Arrange, Act, and Assert sections in each test. This improves readability and maintainability without changing any test logic or behavior.
Replaced xUnit Assert methods with Shouldly assertions in SchemaTypeResolverTests.cs for improved readability. Moved TestEnum inside the test class to limit its scope.
Nested and TestRequest classes are now defined as nested types within ValidationConfigurationBuilderTests, limiting their scope to the test class and improving encapsulation. No changes were made to their implementations.
Replaced xUnit Assert with Shouldly for clearer, more expressive test assertions. Simplified assembly access in SchemaTypeResolverTests and moved TestEnum outside the test class. Improved exception message checks and renamed tests for clarity. Overall, these changes modernize and streamline the test codebase.
Refactored ValidationRuleTests to use Shouldly for assertions, improving readability and error messages. Split PatternRule and EnumRule tests for clearer coverage of exception cases and property validation.
Moved test helper methods to bottom of ValidationDocumentTransformerTests.cs for better organization and changed the class to non-partial. Fixed a misplaced bracket in TypeDocumentTransformerTests.cs to correctly terminate an OpenApiSchema array. No logic changes were made to the helper methods.
Switched to RuntimeHelpers.GetUninitializedObject for creating OpenApiOperationTransformerContext instances, removing usage of obsolete FormatterServices and related warning suppression.
Expanded test coverage across validation, OpenAPI mapping, and utility components. - Added edge case and boundary tests for enum validation, string utilities, and property validation builders. - Introduced extensive tests for OpenAPI path matching, endpoint-to-request type mapping, and schema type resolution. - Verified all constant values and format strings in SchemaConstants. - Improved reliability by covering error conditions, edge cases, and expected behaviors for all validation rule types and operations.
Moved SampleRequest, TestModel, and OtherModel classes to the end of their respective test files to improve code structure and maintainability. No functional changes were made.
Replaced null-forgiving assertions with explicit null checks in unit tests for better error reporting. Also reordered and cleaned up using and namespace statements in ValidationRuleOperationTests.cs for clarity.
Refactored test code to directly construct OpenApiDocumentTransformerContext using object initializers, eliminating the use of reflection and RuntimeHelpers. Updated test helpers and classes to set properties explicitly. Removed most BuildEndpointToRequestTypeMapping tests and reorganized remaining helpers for clarity and maintainability. These changes improve test readability and reduce reliance on internal implementation details.
Added a unit test to ensure that TransformAsync does not modify the OpenApiOperation's Description when ApiDescription.ActionDescriptor is null in AuthorizationPoliciesAndRequirementsOperationTransformerTests. This improves test coverage for edge cases.
Expanded EndpointRequestTypeMapperTests with new cases for non-route endpoints, missing MethodInfo, empty route patterns, and missing EndpointDataSource. Added SimpleEndpointDataSource helper for test setup. Refactored CreateContext in AuthorizationPoliciesAndRequirementsOperationTransformerTests for clarity and null-safety. Added required usings and reorganized test helpers.
Added comprehensive unit tests for OpenApiSchemaHelper covering primitive schema creation, type/format extraction, .NET type mapping, nullable and enum handling, schema reference transformation, and OpenAPI reference resolution. Refactored ResolveReference logic for clarity. Improved code style in EndpointRequestTypeMapperTests.
Refactored SchemaTypeResolver to accept delegates for assembly and type retrieval, improving testability and error handling. Extracted ShouldInspectAssemblyName for direct testing. Updated usages and expanded unit tests to cover exception scenarios and edge cases. Made minor formatting improvements for clarity.
Added TransformAsync_WhenSchemaIsReference_DoesNotModifySchema unit test to EnumSchemaTransformerTests. This test verifies that EnumSchemaTransformer does not alter schemas that are OpenApiSchemaReference instances.
Added a comprehensive suite of unit tests to NullableSchemaReorderTransformerTests, covering edge cases such as null or unresolved schemas, references, and components. Tests verify correct reordering of nullable types in oneOf, allOf, and anyOf arrays, and ensure the transformer handles incomplete or malformed OpenAPI documents without throwing exceptions. This greatly improves test coverage and robustness. Add extensive unit tests for NullableSchemaReorderTransformer Added multiple tests covering TransformAsync edge cases, including null and unresolved references, missing schemas, nested constructs, and correct reordering for allOf/anyOf/oneOf. Improves coverage and robustness of transformer behavior.
Expanded TypeDocumentTransformerTests with many new scenarios: - Array schemas with nullable markers and OneOf/Items handling - Parameter skipping for null schemas and empty names - Nullable enum reference unwrapping and malformed refs - Inlining primitives and IFormFile schemas in requests/components - Skipping non-system references and non-OpenApiPathItem entries - Double-wrapped array unwrapping in various forms - Robustness against null paths/components and non-OpenApiSchema entries Added supporting test types and helpers. Improves coverage and error handling validation.
Reversed OneOf schema expectations in TypeDocumentTransformerTests to match new behavior. Added a test in ValidationConfigurationBuilderTests to ensure using the entire object as a property selector throws an ArgumentException.
- Add SkipAutoProps to Coverlet config to improve coverage accuracy - Remove obsolete ResponseModel from Todos.Delete endpoint - Add/annotate request models and validators with ExcludeFromCodeCoverage - Update PatchTodo integration test to use real model and verify all fields - Refine validation logic and coverage exclusions across endpoints
Refactored the logic for handling nullable wrapper schemas to improve clarity and robustness in distinguishing between nullable markers and actual type schemas. Expanded the OpenAPI specification with detailed validation metadata, including property-level rules, nullable support, and improved documentation. Introduced a new endpoint for FluentValidation edge cases with a corresponding request model and validator, and updated tests to reflect these enhancements.
Added a rule to RequestValidator to ensure that either Uprn is provided, or both Easting and Northing are present. Displays a clear validation message if neither condition is met.
Adjusted the indentation of the .Must() rule for the composite object { x.Uprn, x.Easting, x.Northing } in RequestValidator to improve code readability. No functional changes were made.
Refactored the validation rule for UPRN or easting/northing to move the .WithMessage() call to a new line for better readability. No changes to validation logic or behavior.
Added support for extracting and documenting multi-property validation rules in FluentValidation, improving the accuracy of validation document transformation. Expanded and updated OpenAPI schema definitions and tags for better API documentation clarity. Refreshed test expectations for validation-related OpenAPI components to match the latest schema output.
Modernize test code with collection initializers, explicit types, and null-safe access. Simplify FluentValidation multi-property rule extraction by removing unused parameters and clarifying logic. Improve code readability, consistency, and maintainability without changing core functionality.
SummarySummary
CoverageExampleApi - 94.4%
IeuanWalker.MinimalApi.Endpoints - 87.1%
IeuanWalker.MinimalApi.Endpoints.Generator - 95.9%
|
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.
No description provided.