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

AssertThat with mathematical formulas ignores decimal places #206

Open
tempel3 opened this issue Jul 1, 2020 · 0 comments
Open

AssertThat with mathematical formulas ignores decimal places #206

tempel3 opened this issue Jul 1, 2020 · 0 comments

Comments

@tempel3
Copy link

tempel3 commented Jul 1, 2020

Hi,

just in case someone experiences issues with decimal numbers while using AsserThat.

I have found an interessting behaviour of the used parser when using mixed type values in a mathematical formula.

When mixing int/decimal? the calculation returns a wrong result:
Parser.Parse<double>(validationContextType, "MyValue * 4300").Invoke(new MyClass(){ MyValue = 1.2 }) == 4300 // should be 5160

Replacing the int by a number with a decimal place, the parser works as expected.
Parser.Parse<double>(validationContextType, "MyValue * 4300.0").Invoke(new MyClass(){ MyValue = 1.2 }) == 5160

For constants just add ".0"
[AssertThat("Value1<= Value2 * 4380.0",..)]

I hope this helps someone.

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

No branches or pull requests

1 participant