Skip to content

Improve InputNumber test coverage and add missing scenarios#67059

Open
VigneshwaranGovindharajan wants to merge 8 commits into
dotnet:mainfrom
VigneshwaranGovindharajan:VigneshwaranGovindharajan-1031091-inputnumber-tests
Open

Improve InputNumber test coverage and add missing scenarios#67059
VigneshwaranGovindharajan wants to merge 8 commits into
dotnet:mainfrom
VigneshwaranGovindharajan:VigneshwaranGovindharajan-1031091-inputnumber-tests

Conversation

@VigneshwaranGovindharajan

Copy link
Copy Markdown

Description

This PR significantly enhances the test coverage of the Blazor InputNumber component by adding 69 new test cases, increasing the total test count from 5 to 74 with 100% pass rate.

Original Test Count: 5 tests
New Tests Added: 69 test cases
Final Test Count: 74 tests (100% pass rate)

Test Categories Added:

Validation & Error Handling (12 tests)

  • DisplayAttribute name usage in validation messages
  • Field name fallback when DisplayName is missing
  • Custom parsing error messages
  • Validation message updates on parsing errors
  • Unsupported numeric types (Guid) throwing during rendering

Type Support & Parsing (25 tests)

  • Integer types: int, long, short (min/max boundary values)
  • Floating-point types: float, double, decimal (including large values)
  • Nullable variants: float?, double?, decimal?, int?, long?
  • Invariant culture parsing regardless of current culture
  • Null value formatting

Input Validation (15 tests)

  • Whitespace handling (rejects, accepts leading/trailing)
  • Scientific notation rejection
  • Hex notation rejection
  • Currency symbol rejection
  • Double negative rejection
  • Multiple decimal points rejection
  • Empty string for non-nullable types
  • Plus sign acceptance

Binding & Events (8 tests)

  • ValueChanged callback behavior on valid/invalid input
  • EditContext field change notifications
  • Sequential value changes firing multiple callbacks
  • Invalid input preserving previous valid value
  • Multiple sequential edits

Attributes & Rendering (12 tests)

  • ID attribute (generated and explicit override)
  • Name attribute generation
  • Value attribute reflecting current value
  • Type attribute (default "number", user override to "range")
  • Step attribute (default "any", custom override)
  • Min/Max attributes for range control
  • Custom attributes (data-testid, autocomplete, placeholder, class)
  • AdditionalAttributes preservation in render tree

Format/Parse Round-Trips (4 tests)

  • Format-Parse-Format consistency
  • Parse-Format-Parse consistency
  • Decimal round-trip with various values (0, 1, -1, 99.99, MaxValue/2)

CSS Class Behavior (2 tests)

  • CSS classes added for validation state
  • Valid class applied on valid input

Key Improvements:

  • All tests pass (74/74)
  • No breaking changes
  • No public API changes
  • Follows existing test patterns
  • Uses proper xUnit assertions
  • Covers both EditContext-integrated and standalone scenarios

Test Results:

image

Impact:

  • Eliminates previous coverage gaps for InputNumber component
  • Strengthens regression protection for numeric input behavior
  • Validates all numeric types and their edge cases
  • Ensures proper validation, binding, and rendering behavior
  • Covers both positive and negative scenarios (invalid inputs)

PR Checklist

  • Small and focused — Only test improvements for InputNumber
  • Tests added — 69 new test cases added
  • Code style matches — Follows existing patterns
  • Local build passes
  • Local tests pass (74/74)
  • No breaking changes
  • Issue linked (if applicable) — Not applicable
  • Public API updates — Not applicable
  • XML documentation — Not applicable

@VigneshwaranGovindharajan VigneshwaranGovindharajan requested a review from a team as a code owner June 8, 2026 05:12
@github-actions github-actions Bot added the area-blazor Includes: Blazor, Razor Components label Jun 8, 2026
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Jun 8, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Thanks for your PR, @VigneshwaranGovindharajan. Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-blazor Includes: Blazor, Razor Components community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant