Commit 9194362
authored
[Azure.Messaging.ServiceBus] Fix AmqpMessageBodyTests (Azure#22008)
The `DateTime` and `DateTimeOffset` test values in `AmqpMessageBodyTests.s_amqpValues` were created with `DateTimeOffset.Parse`, which would fail with the following exception when run on a system with a non-US culture:
```
System.TypeInitializationException : The type initializer for 'Azure.Core.Amqp.Tests.AmqpMessageBodyTests' threw an exception.
----> System.FormatException : String was not recognized as a valid DateTime.
at Azure.Core.Amqp.Tests.AmqpMessageBodyTests..ctor()
--FormatException
at System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles, TimeSpan& offset)
at System.DateTimeOffset.Parse(String input)
at Azure.Core.Amqp.Tests.AmqpMessageBodyTests..cctor()
```
By using `new DateTimeOffset(2021, 3, 24, 0, 0, 0, TimeSpan.Zero)` instead of `DateTimeOffset.Parse("3/24/21")` we ensure that the tests pass on any system regardless of its configured culture.1 parent 893aee7 commit 9194362
1 file changed
+6
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
49 | | - | |
| 48 | + | |
| 49 | + | |
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| |||
0 commit comments