Skip to content

Commit

Permalink
Add a quick and dirty test for DateTimeZone
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaNitschke committed Feb 25, 2024
1 parent 7bb6481 commit 4501805
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Marten.NodaTime.Testing/TestData/TargetWithDates.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class TargetWithDates: IEquatable<TargetWithDates>
public DateTime? NullableDateTime { get; set; }
public DateTimeOffset DateTimeOffset { get; set; }
public DateTimeOffset? NullableDateTimeOffset { get; set; }
public DateTimeZone DateTimeZone { get; set; }

public LocalDate LocalDate { get; set; }
public LocalDate? NullableLocalDate { get; set; }
Expand All @@ -23,6 +24,7 @@ internal static TargetWithDates Generate(DateTime? defaultDateTime = null)
var dateTime = defaultDateTime ?? DateTime.UtcNow;
var localDateTime = LocalDateTime.FromDateTime(dateTime);
var instant = Instant.FromDateTimeUtc(dateTime.ToUniversalTime());
var timeZone = DateTimeZoneProviders.Tzdb["Etc/UTC"];

return new TargetWithDates
{
Expand All @@ -33,6 +35,7 @@ internal static TargetWithDates Generate(DateTime? defaultDateTime = null)
NullableDateTimeOffset = dateTime,
LocalDate = localDateTime.Date,
NullableLocalDate = localDateTime.Date,
DateTimeZone = timeZone,
LocalDateTime = localDateTime,
NullableLocalDateTime = localDateTime,
InstantUTC = instant,
Expand All @@ -51,6 +54,7 @@ public bool Equals(TargetWithDates other)
&& NullableDateTime == other.NullableDateTime
&& DateTimeOffset == other.DateTimeOffset
&& NullableDateTimeOffset == other.NullableDateTimeOffset
&& DateTimeZone == other.DateTimeZone
&& LocalDate == other.LocalDate
&& NullableLocalDate == other.NullableLocalDate
&& LocalDateTime == other.LocalDateTime
Expand Down

0 comments on commit 4501805

Please sign in to comment.