Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion exercises/practice/swift-scheduling/.meta/Example.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
3 changes: 3 additions & 0 deletions exercises/practice/swift-scheduling/.meta/tests.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
14 changes: 11 additions & 3 deletions exercises/practice/swift-scheduling/SwiftSchedulingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,26 +105,34 @@ 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);
Assert.Equal(expected, SwiftScheduling.DeliveryDate(meetingStart, "Q1"), TimeSpan.FromSeconds(1));
}

[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);
Assert.Equal(expected, SwiftScheduling.DeliveryDate(meetingStart, "Q4"), TimeSpan.FromSeconds(1));
}

[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));
}
}
Loading