Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Shared.Tests - Add Tests #708

Merged
merged 14 commits into from
Sep 12, 2023
Merged

Shared.Tests - Add Tests #708

merged 14 commits into from
Sep 12, 2023

Conversation

JoseBritto
Copy link
Member

Tests added for CurrencyHelpers to make sure it works with all cultures.

I hardcoded some values because in the tests we know exactly what values go into the test methods and what the expected output is.

Currently all tests are passing except "kea-CV" and "pt-CV". These cultures have $ in the middle of the number:
$1.00 -> 1$00
$2.05 -> 2$05
Also for some reason they also have a zero width space at the end of the number.

@JoseBritto JoseBritto marked this pull request as ready for review September 12, 2023 02:23
@fsobolev
Copy link
Member

Currently all tests are passing except "kea-CV" and "pt-CV". These cultures have $ in the middle of the number:
$1.00 -> 1$00
$2.05 -> 2$05
Also for some reason they also have a zero width space at the end of the number.

The values seem to be correct: these cultures don't have currency sign (that probably explains space at the end) and $ as decimal separator.
kea-CV pt-CV

@JoseBritto
Copy link
Member Author

Those are the expected values. Currently those tests fail.

@fsobolev
Copy link
Member

Those are the expected values. Currently those tests fail.

Ah okay, got it. Let's see...

@JoseBritto
Copy link
Member Author

Assert.Equal() Failure
↓ (pos 0)
Expected: 0$00 ​
Actual: $00

Wasn't sure what the best way to solve it is, so I didnt touch the method itself

@JoseBritto
Copy link
Member Author

JoseBritto commented Sep 12, 2023

TODO:

  1. Fix ToAmountString to account for $ instead of decimal point
  2. Add dotnet test to github workflows? (so we can have future tests automatically run with the other checks)

Not sure of the best way to do either of them at the moment.

@nlogozzo
Copy link
Member

Add dotnet test to github workflows? (so we can have future tests automatically run with the other checks)

I'll make the workflow for this

@nlogozzo nlogozzo self-requested a review September 12, 2023 10:47
@nlogozzo
Copy link
Member

Copy link
Member Author

@JoseBritto JoseBritto left a comment

Choose a reason for hiding this comment

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

Are we fixing the method separately? This one just makes the test pass but doesn't actually fix the problem 🤔 (about the tests)

Copy link
Member Author

@JoseBritto JoseBritto left a comment

Choose a reason for hiding this comment

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

#708 (review)
I meant to leave that comment here. AAh that did the same thing 🤦
Meant to comment on Fyodor's commits

@fsobolev
Copy link
Member

@JoseBritto let me sumarize info about problematic cultures to ensure I don't miss anything:

  1. CurrencySymbol - \u200b (non-printable)
  2. CurrencyDecimalSeparator - $
  3. Format can't be C, it should be minimum C2 (unless overwriteDecimal is true), so 1.0 becomes 1$00
  4. Currency symbol seem to cause misbehavior of string.Remove, string.Replace should be used instead

If all this is correct, I have a fix for the method itself, but the tests are complaining about symbol in the end (I see from errors reports that other than that the values are correct)

@JoseBritto
Copy link
Member Author

@JoseBritto let me sumarize info about problematic cultures to ensure I don't miss anything:

1. `CurrencySymbol` - `\u200b` (non-printable)

2. `CurrencyDecimalSeparator` - `$`

3. Format can't be C, it should be minimum C2 (unless `overwriteDecimal` is true), so 1.0 becomes 1$00

4. Currency symbol seem to cause misbehavior of `string.Remove`, `string.Replace` should be used instead

If all this is correct, I have a fix for the method itself, but the tests are complaining about symbol in the end (I see from errors reports that other than that the values are correct)

Yes. I didn't actually care to check what the currency symbol was actually returning, assumed it was $ as that is what google told me and got confused when I got the invisible character at the end 🤦

@fsobolev
Copy link
Member

3. Format can't be C, it should be minimum C2 (unless overwriteDecimal is true), so 1.0 becomes 1$00

Just noticed 1.2 was becoming 1$2 in AllCulturesShouldWorkWithOverwriteDecimal test, fixed actual value in latest commit.

@fsobolev
Copy link
Member

Just one test left, this time it fails with mm-Mong-MN culture:

Assert.Equal() Failure
             ↓ (pos 3)
Expected: ₮10,920
Actual:   ₮10920
             ↑ (pos 3)

No idea why 🤔

@JoseBritto
Copy link
Member Author

I managed to get all tests to pass and make the tests a lot simpler i think. Will pull in 4f7d2d0 and see if it works with that. If it does can i revert your latest commit? @fsobolev

@fsobolev
Copy link
Member

Will pull in 4f7d2d0 and see if it works with that. If it does can i revert your latest commit? @fsobolev

Sure, feel free to do whatever you need :)

@JoseBritto
Copy link
Member Author

Didn't have to revert. I'm bad at git lol. Anyway, now it should look better than the mess I made yesterday

@nlogozzo nlogozzo requested review from nlogozzo and removed request for nlogozzo September 12, 2023 17:13
@nlogozzo
Copy link
Member

LGTM! Any remaining issues?

@JoseBritto
Copy link
Member Author

JoseBritto commented Sep 12, 2023

Not that I know of. I'll wait for @fsobolev just in case

@nlogozzo nlogozzo requested a review from fsobolev September 12, 2023 17:17
@fsobolev
Copy link
Member

fsobolev commented Sep 12, 2023

Ouch, I didn't know rebase adds person who make a rebase as co-author (at least when using Github Desktop), I hope nobody minds

@fsobolev fsobolev force-pushed the tests branch 2 times, most recently from 8384f0a to bbd9290 Compare September 12, 2023 19:41
@JoseBritto
Copy link
Member Author

Ouch, I didn't know rebase adds person who make a rebase as co-author (at least when using Github Desktop), I hope nobody minds

I don't mind lol. This should now be good to merge right?

@JoseBritto JoseBritto requested a review from nlogozzo September 12, 2023 20:02
@fsobolev
Copy link
Member

This should now be good to merge right?

Yes, I can't merge because I'm the last pusher

@nlogozzo
Copy link
Member

LGTM

@nlogozzo nlogozzo merged commit a32d142 into main Sep 12, 2023
@nlogozzo nlogozzo deleted the tests branch September 12, 2023 20:10
@anaximeno
Copy link

Thanks for implementing the "kea-CV" and "pt-CV", I was here to check something related to this, but seen you've already implemented it, so thanks again.

@nlogozzo nlogozzo added this to the V2023.9.2 milestone Sep 13, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants