![]() ![]() ![]() What I wanted to "simulate" was how the Encode function would operate when the locale has decimal separator different than "point". The CompareEncodedToTemplate function will use the M圜lass.Encode method to write the information to a MemoryStream that then will be compared to a Template text file line per line, and the test will fail when they are not equal. = New Globalization.CultureInfo("es-ES") ' A culture that uses "," as decimal separator Public Sub Encode_CultureWithCommaSeparator_OutputMatchesTemplate()ĭim oldCulture = I did some research and came up with something like this: I wanted to write a unit test to ensure that the encoding functionality will continue to work even when the system locale decimal separator is set to "comma" instead of "point". My component, should however be insensitive to this, meaning that it should always output "point" (for example by making use of the when formatting numbers). The component will be used in an environment where different computers might have different configuration for the "decimal separator" (comma or point). NET library in VB and I have one class M圜lass with an Encode(.) function that is writing, among other things, numeric information as text. I am not calling to String.Format from within the unit test code, String.Format is being called from within the tested functionality. I am asking how to change the decimal separator of locale within a unit test so as to simulate what will happen in a system that has a different decimal separator. Observe: I am not asking how to output text with an specific locale. How do I effectively change the locale decimal separator locally within a unit test so as String.Format("", aDouble) (which AFAIK is locale-dependent) would generate strings with the modified locale? NET (VB or C#) and using for Unit testing: ![]()
0 Comments
Leave a Reply. |