forked from MassTransit/MassTransit
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed MassTransit#5022 - assume UTC when no offset is present.
- Loading branch information
Showing
2 changed files
with
55 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
tests/MassTransit.Tests/Serialization/DateTimeConverter_Specs.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
namespace MassTransit.Tests.Serialization; | ||
|
||
using System; | ||
using MassTransit.Initializers.TypeConverters; | ||
using NUnit.Framework; | ||
|
||
|
||
[TestFixture] | ||
public class DateTimeConverter_Specs | ||
{ | ||
[Test] | ||
public void Should_convert_date_time_min_value() | ||
{ | ||
var converter = new DateTimeTypeConverter(); | ||
|
||
var value = DateTime.MinValue; | ||
|
||
Assert.That(converter.TryConvert(value, out string text)); | ||
|
||
Assert.That(converter.TryConvert(text, out var result)); | ||
|
||
Assert.That(result, Is.EqualTo(value)); | ||
} | ||
|
||
[Test] | ||
public void Should_convert_date_time_offset_min_value() | ||
{ | ||
var converter = new DateTimeOffsetTypeConverter(); | ||
|
||
var value = DateTimeOffset.MinValue; | ||
|
||
Assert.That(converter.TryConvert(value, out string text)); | ||
|
||
Assert.That(converter.TryConvert(text, out var result)); | ||
|
||
Assert.That(result, Is.EqualTo(value)); | ||
} | ||
|
||
[Test] | ||
public void Should_convert_date_time_min_value_to_offset() | ||
{ | ||
var converter = new DateTimeTypeConverter(); | ||
var offsetConverter = new DateTimeOffsetTypeConverter(); | ||
|
||
var value = DateTime.MinValue.ToUniversalTime(); | ||
|
||
Assert.That(converter.TryConvert(value, out string text)); | ||
|
||
Assert.That(offsetConverter.TryConvert(text, out var result)); | ||
|
||
Assert.That(result.UtcDateTime, Is.EqualTo(value)); | ||
} | ||
} |