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

Convert decimal strings with comma separator #6

Open
pz1337 opened this issue May 25, 2022 · 1 comment
Open

Convert decimal strings with comma separator #6

pz1337 opened this issue May 25, 2022 · 1 comment
Labels
Bug Something isn't working
Milestone

Comments

@pz1337
Copy link
Contributor

pz1337 commented May 25, 2022

Expected behavior

The class SwapStringToBytes can convert strings declared as decimal with a comma as decimal separator to doubles. (See test code below.)
The class SwapStringToBytes has a test class SwapStringToBytesTests.
The class SwapStringToBytes is in the namespace PAQO.Core.Facets.
The class SwapBytesToString is in the namespace PAQO.Core.Facets.
The class SwapBytesToStringTests is in the namespace PAQO.Core.Facets.Test.

Actual behavior

The class SwapStringToBytes cannot convert strings declared as decimal with a comma as decimal separator to doubles.
The class SwapStringToBytes has no test class.
The namespaces are wrong.

Steps to reproduce the behavior

using PAQO.Core.Prop;
using Xunit;

namespace PAQO.Core.Facets.Test
{
    public sealed class SwapStringToBytesTests
    {
        [Fact]
        public void DeliversDoubleForCommaDecimalSeparator()
        {
            Assert.Equal(
                6083.15,
                new DecimalProp.AsDouble(
                    new SwapStringToBytes().Flip("decimal", "6083,15")
                ).Value()
            );
        }
    }
}

The log given by the failure.

Mention any other details that might be useful

@pz1337 pz1337 added the Bug Something isn't working label May 25, 2022
@pz1337 pz1337 added this to the next milestone May 25, 2022
@koeeenig
Copy link
Member

I see two possible solutions to this problem.

  1. Provide a CultureInfo to class SwapStringToBytes which is used to parse numerical values.
  2. It's the app reponsibilitiy to transform the numeric value into a Culture Invariant format which is used by PAQO to parse numeric values from string.

The first approach is my personal favorit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants