-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix partly broken import of excluded match dates (#196)
* Fix `GermanHoliday.ProcessHoliday` method to set correct `dateFrom` and `dateTo`. * Add more constructors to `GermanHolidayImporter` to import more than 1 file in one go. * Remove ignored test case and added new one in `GermanHolidayImporterTests`. * Rename `EnumerableValueTupleExtensions.cs` to `EnumerableRangeExtensions.cs` for consecutive range calculations. * Add `EnumerableValueTupleExtensionsTests` for `EnumerableValueTupleExtensions` methods.*
- Loading branch information
Showing
10 changed files
with
319 additions
and
83 deletions.
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
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
12 changes: 12 additions & 0 deletions
12
TournamentManager/TournamentManager.Tests/Assets/Single_Holiday_To_Add.xml
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,12 @@ | ||
<?xml version='1.0' encoding="UTF-8" standalone='yes'?> | ||
<Holidays> | ||
<Holiday Action="add" Id="Neujahr"> | ||
<Type>Public</Type> | ||
<Name>Sample New Year</Name> | ||
<DateFrom>2024-01-01</DateFrom> | ||
<DateTo>2024-01-01</DateTo> | ||
<PublicHolidayStateIds> | ||
<StateId>Bayern</StateId> | ||
</PublicHolidayStateIds> | ||
</Holiday> | ||
</Holidays> |
8 changes: 8 additions & 0 deletions
8
TournamentManager/TournamentManager.Tests/Assets/Single_Holiday_To_Remove.xml
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,8 @@ | ||
<?xml version='1.0' encoding="UTF-8" standalone='yes'?> | ||
<Holidays> | ||
<Holiday Action="remove" Id="Neujahr"> | ||
<Type>Public</Type> | ||
<DateFrom>2024-01-01</DateFrom> | ||
<DateTo>2024-01-01</DateTo> | ||
</Holiday> | ||
</Holidays> |
66 changes: 66 additions & 0 deletions
66
...ger/TournamentManager.Tests/Importers/ExcludeDates/EnumerableValueTupleExtensionsTests.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,66 @@ | ||
using NUnit.Framework; | ||
using TournamentManager.Importers.ExcludeDates; | ||
|
||
namespace TournamentManager.Tests.Importers.ExcludeDates; | ||
|
||
[TestFixture] | ||
internal class EnumerableValueTupleExtensionsTests | ||
{ | ||
[Test] | ||
public void IntegerRanges_ShouldBeConsecutive() | ||
{ | ||
// Unsorted list of integers with missing numbers | ||
var intList = new List<int> | ||
{ | ||
// group #3: number 7 missing | ||
10, | ||
9, | ||
8, | ||
// group #1 | ||
2, | ||
3, | ||
4, | ||
// group #2: number 5 missing | ||
6 | ||
}; | ||
|
||
var ranges = intList.ConsecutiveRanges().ToList(); | ||
Assert.Multiple(() => | ||
{ | ||
Assert.That(ranges, Has.Count.EqualTo(3)); | ||
Assert.That(ranges[0], Is.EqualTo((2, 4))); | ||
Assert.That(ranges[1], Is.EqualTo((6, 6))); | ||
Assert.That(ranges[2], Is.EqualTo((8, 10))); | ||
}); | ||
} | ||
|
||
[Test] | ||
public void DateOnlyRanges_ShouldBeConsecutive() | ||
{ | ||
// Unsorted list of DateTime with missing dates | ||
var dateOnlyList = new List<DateOnly> | ||
{ | ||
// group #3: number 7 Oct missing | ||
new (2024, 10, 10), | ||
new (2024, 10, 9), | ||
new (2024, 10, 8), | ||
// group #1 | ||
new (2024, 10, 2), | ||
new (2024, 10, 3), | ||
new (2024, 10, 4), | ||
// group #2: number 5 Oct missing | ||
new (2024, 10, 6) | ||
}; | ||
|
||
var ranges = dateOnlyList.ConsecutiveRanges().ToList(); | ||
Assert.Multiple(() => | ||
{ | ||
Assert.That(ranges, Has.Count.EqualTo(3)); | ||
Assert.That(ranges[0], Is.EqualTo((new DateOnly(2024, 10, 2), new DateOnly(2024, 10, 4)))); | ||
Assert.That(ranges[1], Is.EqualTo((new DateOnly(2024, 10, 6), new DateOnly(2024, 10, 6)))); | ||
Assert.That(ranges[2], Is.EqualTo((new DateOnly(2024, 10, 8), new DateOnly(2024, 10, 10)))); | ||
}); | ||
} | ||
} | ||
|
||
|
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
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: 0 additions & 53 deletions
53
TournamentManager/TournamentManager/Importers/ExcludeDates/EnumberableExtensions.cs
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.