-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from skuill/feature/28_lyricfind_region_availa…
…bility Feature/28 lyricfind region availability
- Loading branch information
Showing
18 changed files
with
262 additions
and
61 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
LyricsScraperNET.TestShared/Attributes/RegionalTestAttribute.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,54 @@ | ||
using System; | ||
using System.Globalization; | ||
using System.Linq; | ||
using Xunit; | ||
|
||
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] | ||
public class RegionalTestTheoryAttribute : TheoryAttribute | ||
{ | ||
public RegionalTestTheoryAttribute(string[] includeRegions = null, string[] excludeRegions = null) | ||
{ | ||
if (!ShouldRunTest(includeRegions, excludeRegions)) | ||
{ | ||
Skip = GenerateSkipMessage(includeRegions, excludeRegions); | ||
} | ||
} | ||
|
||
private static bool ShouldRunTest(string[] includeRegions, string[] excludeRegions) | ||
{ | ||
var currentRegion = RegionInfo.CurrentRegion.Name; | ||
|
||
// If regions are specified to be included, run only if the current region is in the list. | ||
if (includeRegions != null && includeRegions.Length > 0) | ||
{ | ||
if (!includeRegions.Any(code => string.Equals(currentRegion, code, StringComparison.OrdinalIgnoreCase))) | ||
{ | ||
return false; | ||
} | ||
} | ||
|
||
// If regions are specified to be excluded, do not run if the current region is in the list. | ||
if (excludeRegions != null && excludeRegions.Length > 0) | ||
{ | ||
if (excludeRegions.Any(code => string.Equals(currentRegion, code, StringComparison.OrdinalIgnoreCase))) | ||
{ | ||
return false; | ||
} | ||
} | ||
|
||
return true; | ||
} | ||
|
||
private static string GenerateSkipMessage(string[] includeRegions, string[] excludeRegions) | ||
{ | ||
var includeMessage = includeRegions != null && includeRegions.Length > 0 | ||
? $"Include: {string.Join(", ", includeRegions)}." | ||
: string.Empty; | ||
|
||
var excludeMessage = excludeRegions != null && excludeRegions.Length > 0 | ||
? $"Exclude: {string.Join(", ", excludeRegions)}." | ||
: string.Empty; | ||
|
||
return $"Test skipped. {includeMessage} {excludeMessage}".Trim(); | ||
} | ||
} |
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
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
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
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
8 changes: 0 additions & 8 deletions
8
Tests/LyricsScraperNET.IntegrationTest/Providers/LyricFind/instrumental_test_data.json
This file was deleted.
Oops, something went wrong.
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
8 changes: 0 additions & 8 deletions
8
Tests/LyricsScraperNET.IntegrationTest/Providers/SongLyrics/instrumental_test_data.json
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.