Skip to content
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

Add empty string support, culture based cast #1912

Merged
merged 4 commits into from
Jan 17, 2025

Conversation

ivan-rosales-rieloff
Copy link
Contributor

Add empty string support and culture base type conversion, update test suite to use culture and validate string to number conversion and empty string to zero value conversion.

Use component culture parameter to cast value to decimal type.

@@ -489,14 +490,91 @@ public void Numeric_Supports_TypeConverter()

var component = ctx.RenderComponent<RadzenNumeric<Dollars>>(
ComponentParameter.CreateParameter(nameof(RadzenNumeric<Dollars>.Format), format),
ComponentParameter.CreateParameter(nameof(RadzenNumeric<Dollars>.Value), valueToTest)
ComponentParameter.CreateParameter(nameof(RadzenNumeric<Dollars>.Value), valueToTest),
ComponentParameter.CreateParameter(nameof(RadzenNumeric<Dollars>.Culture), System.Globalization.CultureInfo.InvariantCulture)
);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why you need to specify Culture parameter here? This property is not mandatory, please make sure that everything works as expected without specified Culture.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I add a test without culture, in my machine the culture is es-CL and the test fail if I don't specify culture, to ensure the string conversion I use

Assert.Contains($" value=\"{valueToTest.ToString(format, System.Globalization.CultureInfo.CurrentCulture)}\"", component.Markup);

to validate the render result, also add a new test using a specific culture to test both cases with and without culture set

@enchev enchev merged commit ab65a5a into radzenhq:master Jan 17, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants