Skip to content

Conversation

@0xced
Copy link
Contributor

@0xced 0xced commented Jun 21, 2021

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.

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.
@ghost ghost added Azure.Core customer-reported Issues that are reported by GitHub users external to the Azure organization. labels Jun 21, 2021
@ghost
Copy link

ghost commented Jun 21, 2021

Thank you for your contribution @0xced! We will review the pull request and get back to you soon.

@ghost ghost added the Community Contribution Community members are working on the issue label Jun 21, 2021
@jsquire jsquire changed the title [Azure.Messaging.ServiceBus] Fix AmqpMessageBodyTests [Azure.Core.Amqp] Fix AmqpMessageBodyTests Jun 21, 2021
Copy link
Member

@jsquire jsquire left a comment

Choose a reason for hiding this comment

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

Hi @0xced. Thank you for your contribution and for helping to improve the Azure SDK experience. The change looks good to me.

The CI failures that we're seeing appear to be related to a missing file in another area. Would you be so kind as to try rebasing your changes onto the latest from main and see if that resolves?

@jsquire jsquire requested a review from JoshLove-msft June 21, 2021 13:41
@jsquire
Copy link
Member

jsquire commented Jun 21, 2021

@JoshLove-msft: Would you mind taking a look as well? I think the CI failures may be related to one of the recent Event Grid changes...

@0xced
Copy link
Contributor Author

0xced commented Jun 21, 2021

Would you be so kind as to try rebasing your changes onto the latest from main and see if that resolves?

The latest commit on main (cbad4bb) is from three days ago and I just did this pull request today on top of this commit so there's nothing new I can rebase on. Maybe another branch needs to be merged on main first?

@JoshLove-msft
Copy link
Member

Created #22012

@JoshLove-msft
Copy link
Member

/azp run net - core - ci

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@JoshLove-msft JoshLove-msft enabled auto-merge (squash) June 21, 2021 20:22
@JoshLove-msft JoshLove-msft merged commit 9194362 into Azure:main Jun 22, 2021
@0xced 0xced deleted the fix-AmqpMessageBodyTests branch June 22, 2021 07:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Azure.Core Community Contribution Community members are working on the issue customer-reported Issues that are reported by GitHub users external to the Azure organization.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants