diff --git a/exercises/practice/swift-scheduling/.meta/Example.cs b/exercises/practice/swift-scheduling/.meta/Example.cs index 251c33790..3014ee286 100644 --- a/exercises/practice/swift-scheduling/.meta/Example.cs +++ b/exercises/practice/swift-scheduling/.meta/Example.cs @@ -18,7 +18,7 @@ public static DateTime DeliveryDate(DateTime meetingStart, string description) = }, _ when description.StartsWith('Q') => int.Parse(description[1..]) switch { - var quarter when quarter * 3 > meetingStart.Month => meetingStart.NthQuarter(quarter).LastWorkDay().AtHour(8), + var quarter when quarter * 3 >= meetingStart.Month => meetingStart.NthQuarter(quarter).LastWorkDay().AtHour(8), var quarter => meetingStart.AddYears(1).NthQuarter(quarter).LastWorkDay().AtHour(8) }, _ => throw new ArgumentException("Invalid date"), diff --git a/exercises/practice/swift-scheduling/.meta/tests.toml b/exercises/practice/swift-scheduling/.meta/tests.toml index 7cc3e4158..f2475c9ea 100644 --- a/exercises/practice/swift-scheduling/.meta/tests.toml +++ b/exercises/practice/swift-scheduling/.meta/tests.toml @@ -56,3 +56,6 @@ description = "Q4 in the second quarter translates to the last workday of the fo [c920886c-44ad-4d34-a156-dc4176186581] description = "Q3 in the fourth quarter translates to the last workday of the third quarter of next year" + +[7c8f1616-be62-417e-bbd5-a60fa743eccc] +description = "Q2 starting in the last month of the second quarter translates to the last workday of the second quarter of this year" diff --git a/exercises/practice/swift-scheduling/SwiftSchedulingTests.cs b/exercises/practice/swift-scheduling/SwiftSchedulingTests.cs index 93454340e..ef948cf39 100644 --- a/exercises/practice/swift-scheduling/SwiftSchedulingTests.cs +++ b/exercises/practice/swift-scheduling/SwiftSchedulingTests.cs @@ -105,7 +105,7 @@ public void Four_m_in_the_ninth_month_translates_to_the_first_workday_of_the_fou } [Fact(Skip = "Remove this Skip property to run this test")] - public void Q1_in_the_first_quarter_translates_to_the_last_workday_of_the_first_quarter_of_this_year() + public void Q_1_in_the_first_quarter_translates_to_the_last_workday_of_the_first_quarter_of_this_year() { var meetingStart = new DateTime(2003, 1, 1, 10, 45, 0); var expected = new DateTime(2003, 3, 31, 8, 0, 0); @@ -113,7 +113,7 @@ public void Q1_in_the_first_quarter_translates_to_the_last_workday_of_the_first_ } [Fact(Skip = "Remove this Skip property to run this test")] - public void Q4_in_the_second_quarter_translates_to_the_last_workday_of_the_fourth_quarter_of_this_year() + public void Q_4_in_the_second_quarter_translates_to_the_last_workday_of_the_fourth_quarter_of_this_year() { var meetingStart = new DateTime(2001, 4, 9, 9, 0, 0); var expected = new DateTime(2001, 12, 31, 8, 0, 0); @@ -121,10 +121,18 @@ public void Q4_in_the_second_quarter_translates_to_the_last_workday_of_the_fourt } [Fact(Skip = "Remove this Skip property to run this test")] - public void Q3_in_the_fourth_quarter_translates_to_the_last_workday_of_the_third_quarter_of_next_year() + public void Q_3_in_the_fourth_quarter_translates_to_the_last_workday_of_the_third_quarter_of_next_year() { var meetingStart = new DateTime(2022, 10, 6, 11, 0, 0); var expected = new DateTime(2023, 9, 29, 8, 0, 0); Assert.Equal(expected, SwiftScheduling.DeliveryDate(meetingStart, "Q3"), TimeSpan.FromSeconds(1)); } + + [Fact(Skip = "Remove this Skip property to run this test")] + public void Q_2_starting_in_the_last_month_of_the_second_quarter_translates_to_the_last_workday_of_the_second_quarter_of_this_year() + { + var meetingStart = new DateTime(2019, 6, 15, 9, 50, 0); + var expected = new DateTime(2019, 6, 28, 8, 0, 0); + Assert.Equal(expected, SwiftScheduling.DeliveryDate(meetingStart, "Q2"), TimeSpan.FromSeconds(1)); + } }