|
2 | 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
3 | 3 |
|
4 | 4 | using DocumentFormat.OpenXml.Spreadsheet;
|
| 5 | +using DocumentFormat.OpenXml.Tests.Common; |
5 | 6 | using System;
|
6 | 7 | using System.Collections.Generic;
|
| 8 | +using System.Globalization; |
| 9 | +using System.Threading; |
7 | 10 | using Xunit;
|
8 | 11 |
|
9 | 12 | namespace DocumentFormat.OpenXml.Tests
|
@@ -74,6 +77,30 @@ public void CellDoubleTest(double num)
|
74 | 77 | Assert.Equal(num, result);
|
75 | 78 | }
|
76 | 79 |
|
| 80 | + [InlineData("fr-FR")] |
| 81 | + [InlineData("de-DE")] |
| 82 | + [InlineData("zh-CH")] |
| 83 | + [InlineData("ru-RU")] |
| 84 | + [InlineData("en-US")] |
| 85 | + [InlineData("tr-TR")] |
| 86 | + [InlineData("ar-EG")] |
| 87 | + [InlineData("fa-IR")] |
| 88 | + [Theory] |
| 89 | + public void CellDoubleCultureTest(string culture) |
| 90 | + { |
| 91 | + // Change current culture |
| 92 | + using (new CultureInfoTester(culture)) |
| 93 | + { |
| 94 | + // Set to a double value |
| 95 | + double num = 103.2; |
| 96 | + var value = new CellValue(num); |
| 97 | + |
| 98 | + // Ensure that thread culture is not used. |
| 99 | + Assert.Equal("103.2", value.Text); |
| 100 | + Assert.Equal("103.2", value.InnerText); |
| 101 | + } |
| 102 | + } |
| 103 | + |
77 | 104 | [InlineData("987.6E+30", 9.876E+32)]
|
78 | 105 | [InlineData("-12.34E-20", -1.234E-19)]
|
79 | 106 | [Theory]
|
@@ -180,6 +207,30 @@ public void CellDecimalTestNegative(string input)
|
180 | 207 | Assert.False(value.TryGetDecimal(out _));
|
181 | 208 | }
|
182 | 209 |
|
| 210 | + [InlineData("fr-FR")] |
| 211 | + [InlineData("de-DE")] |
| 212 | + [InlineData("zh-CH")] |
| 213 | + [InlineData("ru-RU")] |
| 214 | + [InlineData("en-US")] |
| 215 | + [InlineData("tr-TR")] |
| 216 | + [InlineData("ar-EG")] |
| 217 | + [InlineData("fa-IR")] |
| 218 | + [Theory] |
| 219 | + public void CellDecimalCultureTest(string culture) |
| 220 | + { |
| 221 | + // Change current culture |
| 222 | + using (new CultureInfoTester(culture)) |
| 223 | + { |
| 224 | + // Set to a decimal value |
| 225 | + decimal num = 6049.9M; |
| 226 | + var value = new CellValue(num); |
| 227 | + |
| 228 | + // Ensure that thread culture is not used. |
| 229 | + Assert.Equal("6049.9", value.Text); |
| 230 | + Assert.Equal("6049.9", value.InnerText); |
| 231 | + } |
| 232 | + } |
| 233 | + |
183 | 234 | [InlineData("0", false)]
|
184 | 235 | [InlineData("false", false)]
|
185 | 236 | [InlineData("1", true)]
|
|
0 commit comments