Skip to content

Commit

Permalink
#17 Refactoring. Set instrumentul result as Success.
Browse files Browse the repository at this point in the history
  • Loading branch information
skuill committed Dec 17, 2023
1 parent 9fda657 commit 8851b32
Show file tree
Hide file tree
Showing 22 changed files with 30 additions and 29 deletions.
1 change: 1 addition & 0 deletions LyricsScraperNET/Extensions/SearchResultExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ internal static SearchResult AppendResponseMessage(this SearchResult searchResul

internal static SearchResult AddInstrumental(this SearchResult searchResult, bool instrumental)
{
searchResult.ResponseStatusCode = ResponseStatusCode.Success;
searchResult.Instrumental = instrumental;
return searchResult;
}
Expand Down
4 changes: 2 additions & 2 deletions LyricsScraperNET/LyricsScraperClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public SearchResult SearchLyric(SearchRequest searchRequest)
foreach (var externalProvider in GetAvailableProvidersForSearchRequest(searchRequest))
{
var providerSearchResult = externalProvider.SearchLyric(searchRequest);
if (!providerSearchResult.IsEmpty())
if (!providerSearchResult.IsEmpty() || providerSearchResult.Instrumental)
{
return providerSearchResult;
}
Expand Down Expand Up @@ -102,7 +102,7 @@ public async Task<SearchResult> SearchLyricAsync(SearchRequest searchRequest)
foreach (var externalProvider in GetAvailableProvidersForSearchRequest(searchRequest))
{
var providerSearchResult = await externalProvider.SearchLyricAsync(searchRequest);
if (!providerSearchResult.IsEmpty())
if (!providerSearchResult.IsEmpty() || providerSearchResult.Instrumental)
{
return providerSearchResult;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,28 +40,28 @@
<None Update="Providers\LyricFind\Resources\Lyrics_Result_01.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Providers\LyricFind\test_data.json">
<None Update="Providers\LyricFind\lyric_test_data.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Providers\Musixmatch\Resources\Lyrics_Result_01.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Providers\Musixmatch\test_data.json">
<None Update="Providers\Musixmatch\lyric_test_data.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Providers\Genius\Resources\Lyrics_Result_01.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Providers\Genius\test_data.json">
<None Update="Providers\Genius\lyric_test_data.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Providers\AZLyrics\test_data.json">
<None Update="Providers\AZLyrics\lyric_test_data.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Providers\SongLyrics\Resources\Lyrics_Result_01.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Providers\SongLyrics\test_data.json">
<None Update="Providers\SongLyrics\lyric_test_data.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ namespace LyricsScraperNET.IntegrationTest.Providers.AZLyrics
public class AZLyricsProviderTest : ProviderTestBase
{
[Theory]
[MemberData(nameof(GetTestData), parameters: "Providers\\AZLyrics\\test_data.json")]
public void SearchLyric_IntegrationDynamicData_AreEqual(LyricsTestData testData)
[MemberData(nameof(GetTestData), parameters: "Providers\\AZLyrics\\lyric_test_data.json")]
public void SearchLyric_IntegrationDynamicData_Success(LyricsTestData testData)
{
// Arrange
var lyricsClient = new AZLyricsProvider();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ namespace LyricsScraperNET.IntegrationTest.Providers.Genius
public class GeniusProviderTest : ProviderTestBase
{
[Theory]
[MemberData(nameof(GetTestData), parameters: "Providers\\Genius\\test_data.json")]
public void SearchLyric_IntegrationDynamicData_AreEqual(LyricsTestData testData)
[MemberData(nameof(GetTestData), parameters: "Providers\\Genius\\lyric_test_data.json")]
public void SearchLyric_IntegrationDynamicData_Success(LyricsTestData testData)
{
// Arrange
var lyricsClient = new GeniusProvider();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ namespace LyricsScraperNET.IntegrationTest.Providers.LyricFind
public class LyricFindProviderTest : ProviderTestBase
{
[Theory]
[MemberData(nameof(GetTestData), parameters: "Providers\\LyricFind\\test_data.json")]
public void SearchLyric_IntegrationDynamicData_AreEqual(LyricsTestData testData)
[MemberData(nameof(GetTestData), parameters: "Providers\\LyricFind\\lyric_test_data.json")]
public void SearchLyric_IntegrationDynamicData_Success(LyricsTestData testData)
{
// Arrange
var lyricsClient = new LyricFindProvider();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ namespace LyricsScraperNET.IntegrationTest.Providers.Musixmatch
public class MusixmatchProviderTest : ProviderTestBase
{
[Theory]
[MemberData(nameof(GetTestData), parameters: "Providers\\Musixmatch\\test_data.json")]
public void SearchLyric_IntegrationDynamicData_AreEqual(LyricsTestData testData)
[MemberData(nameof(GetTestData), parameters: "Providers\\Musixmatch\\lyric_test_data.json")]
public void SearchLyric_IntegrationDynamicData_Success(LyricsTestData testData)
{
// Arrange
var lyricsClient = new MusixmatchProvider();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ namespace LyricsScraperNET.IntegrationTest.Providers.SongLyrics
public class SongLyricsProviderTest : ProviderTestBase
{
[Theory]
[MemberData(nameof(GetTestData), parameters: "Providers\\SongLyrics\\test_data.json")]
public void SearchLyric_IntegrationDynamicData_AreEqual(LyricsTestData testData)
[MemberData(nameof(GetTestData), parameters: "Providers\\SongLyrics\\lyric_test_data.json")]
public void SearchLyric_IntegrationDynamicData_Success(LyricsTestData testData)
{
// Arrange
var lyricsClient = new SongLyricsProvider();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<None Update="Providers\Genius\Resources\Lyrics_Result_01.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Providers\Genius\test_data.json">
<None Update="Providers\Genius\lyric_test_data.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Providers\AZLyrics\Resources\Lyrics_Result_01.txt">
Expand All @@ -46,7 +46,7 @@
<None Update="Providers\AZLyrics\Resources\Lyrics_HtmlPage_01.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Providers\AZLyrics\test_data.json">
<None Update="Providers\AZLyrics\lyric_test_data.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Providers\LyricFind\Resources\Lyrics_HtmlPage_01.txt">
Expand All @@ -55,7 +55,7 @@
<None Update="Providers\LyricFind\Resources\Lyrics_Result_01.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Providers\LyricFind\test_data.json">
<None Update="Providers\LyricFind\lyric_test_data.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Providers\SongLyrics\Resources\Lyrics_HtmlPage_01.txt">
Expand All @@ -64,7 +64,7 @@
<None Update="Providers\SongLyrics\Resources\Lyrics_Result_01.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Providers\SongLyrics\test_data.json">
<None Update="Providers\SongLyrics\lyric_test_data.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Resources\full_test_settings.json">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ namespace LyricsScraperNET.UnitTest.Providers.AZLyrics
public class AZLyricsProviderTest : ProviderTestBase
{
[Theory]
[MemberData(nameof(GetTestData), parameters: "Providers\\AZLyrics\\test_data.json")]
public void SearchLyric_UnitDynamicData_AreEqual(LyricsTestData testData)
[MemberData(nameof(GetTestData), parameters: "Providers\\AZLyrics\\lyric_test_data.json")]
public void SearchLyric_UnitDynamicData_Success(LyricsTestData testData)
{
// Arrange
var lyricsClient = new AZLyricsProvider();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ namespace LyricsScraperNET.UnitTest.Providers.Genius
public class GeniusProviderTest : ProviderTestBase
{
[Theory]
[MemberData(nameof(GetTestData), parameters: "Providers\\Genius\\test_data.json")]
public void SearchLyric_UnitDynamicData_AreEqual(LyricsTestData testData)
[MemberData(nameof(GetTestData), parameters: "Providers\\Genius\\lyric_test_data.json")]
public void SearchLyric_UnitDynamicData_Success(LyricsTestData testData)
{
// Arrange
var lyricsClient = new GeniusProvider();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ namespace LyricsScraperNET.UnitTest.Providers.LyricFind
public class LyricFindProviderTest : ProviderTestBase
{
[Theory]
[MemberData(nameof(GetTestData), parameters: "Providers\\LyricFind\\test_data.json")]
public void SearchLyric_UnitDynamicData_AreEqual(LyricsTestData testData)
[MemberData(nameof(GetTestData), parameters: "Providers\\LyricFind\\lyric_test_data.json")]
public void SearchLyric_UnitDynamicData_Success(LyricsTestData testData)
{
// Arrange
var lyricsClient = new LyricFindProvider();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ namespace LyricsScraperNET.UnitTest.Providers.SongLyrics
public class SongLyricsProviderTest : ProviderTestBase
{
[Theory]
[MemberData(nameof(GetTestData), parameters: "Providers\\SongLyrics\\test_data.json")]
public void SearchLyric_UnitDynamicData_AreEqual(LyricsTestData testData)
[MemberData(nameof(GetTestData), parameters: "Providers\\SongLyrics\\lyric_test_data.json")]
public void SearchLyric_UnitDynamicData_Success(LyricsTestData testData)
{
// Arrange
var lyricsClient = new SongLyricsProvider();
Expand Down

0 comments on commit 8851b32

Please sign in to comment.