From 628ead1ebbfd834de39c76e3432eb356366d45f7 Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Thu, 30 Mar 2023 20:44:32 +0100 Subject: [PATCH] test: add tests for GetIso8601WeekOfYear --- X10D.Tests/src/Time/DateTimeOffsetTests.cs | 27 ++++++++++++++++++++++ X10D.Tests/src/Time/DateTimeTests.cs | 27 ++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/X10D.Tests/src/Time/DateTimeOffsetTests.cs b/X10D.Tests/src/Time/DateTimeOffsetTests.cs index d79ac4d..eb2d937 100644 --- a/X10D.Tests/src/Time/DateTimeOffsetTests.cs +++ b/X10D.Tests/src/Time/DateTimeOffsetTests.cs @@ -37,6 +37,33 @@ public class DateTimeOffsetTests Assert.AreEqual(new DateTime(today.Year, today.Month, 1), today.FirstDayOfMonth()); } + [TestMethod] + public void GetIso8601WeekOfYear_ShouldReturn1_Given4January1970() + { + DateTimeOffset date = new DateTime(1970, 1, 4); + int iso8601WeekOfYear = date.GetIso8601WeekOfYear(); + + Assert.AreEqual(1, iso8601WeekOfYear); + } + + [TestMethod] + public void GetIso8601WeekOfYear_ShouldReturn1_Given31December1969() + { + DateTimeOffset date = new DateTime(1969, 12, 31); + int iso8601WeekOfYear = date.GetIso8601WeekOfYear(); + + Assert.AreEqual(1, iso8601WeekOfYear); + } + + [TestMethod] + public void GetIso8601WeekOfYear_ShouldReturn53_Given31December1970() + { + DateTimeOffset date = new DateTime(1970, 12, 31); + int iso8601WeekOfYear = date.GetIso8601WeekOfYear(); + + Assert.AreEqual(53, iso8601WeekOfYear); + } + [TestMethod] public void IsLeapYear_ShouldBeFalse_Given1999() { diff --git a/X10D.Tests/src/Time/DateTimeTests.cs b/X10D.Tests/src/Time/DateTimeTests.cs index b6c3174..d08b78e 100644 --- a/X10D.Tests/src/Time/DateTimeTests.cs +++ b/X10D.Tests/src/Time/DateTimeTests.cs @@ -37,6 +37,33 @@ public class DateTimeTests Assert.AreEqual(new DateTime(today.Year, today.Month, 1), today.FirstDayOfMonth()); } + [TestMethod] + public void GetIso8601WeekOfYear_ShouldReturn1_Given4January1970() + { + var date = new DateTime(1970, 1, 4); + int iso8601WeekOfYear = date.GetIso8601WeekOfYear(); + + Assert.AreEqual(1, iso8601WeekOfYear); + } + + [TestMethod] + public void GetIso8601WeekOfYear_ShouldReturn1_Given31December1969() + { + var date = new DateTime(1969, 12, 31); + int iso8601WeekOfYear = date.GetIso8601WeekOfYear(); + + Assert.AreEqual(1, iso8601WeekOfYear); + } + + [TestMethod] + public void GetIso8601WeekOfYear_ShouldReturn53_Given31December1970() + { + var date = new DateTime(1970, 12, 31); + int iso8601WeekOfYear = date.GetIso8601WeekOfYear(); + + Assert.AreEqual(53, iso8601WeekOfYear); + } + [TestMethod] public void IsLeapYear_ShouldBeFalse_Given1999() {