-
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 #32 from skuill/feature/30_async_tests
- Loading branch information
Showing
15 changed files
with
461 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using LyricsScraperNET.Providers.Abstract; | ||
using System.Net; | ||
|
||
namespace LyricsScraperNET.Providers.SongLyrics | ||
{ | ||
internal sealed class SongLyricsParser : IExternalProviderLyricParser | ||
{ | ||
public string Parse(string lyric) | ||
{ | ||
lyric = WebUtility.HtmlDecode(lyric); | ||
|
||
return lyric?.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
58 changes: 58 additions & 0 deletions
58
Tests/LyricsScraperNET.IntegrationTest/LyricsScraperClientTests.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,58 @@ | ||
using LyricsScraperNET.Models.Requests; | ||
using LyricsScraperNET.Models.Responses; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
|
||
namespace LyricsScraperNET.IntegrationTest | ||
{ | ||
public class LyricsScraperClientTests | ||
{ | ||
[Fact] | ||
public void SearchLyric_WithDefaultExample_ShouldReturnSuccessfulSearchResult() | ||
{ | ||
// Arrange | ||
string artistToSearch = "Parkway Drive"; | ||
string songToSearch = "Idols And Anchors"; | ||
ILyricsScraperClient lyricsScraperClient | ||
= new LyricsScraperClient() | ||
.WithAllProviders(); | ||
|
||
var searchRequest = new ArtistAndSongSearchRequest(artistToSearch, songToSearch); | ||
|
||
// Act | ||
var searchResult = lyricsScraperClient.SearchLyric(searchRequest); | ||
|
||
// Assert | ||
Assert.NotNull(searchResult); | ||
Assert.False(searchResult.IsEmpty()); | ||
Assert.Equal(ResponseStatusCode.Success, searchResult.ResponseStatusCode); | ||
Assert.True(string.IsNullOrEmpty(searchResult.ResponseMessage)); | ||
Assert.NotNull(searchResult.LyricText); | ||
Assert.False(searchResult.Instrumental); | ||
} | ||
|
||
[Fact] | ||
public async Task SearchLyricAsync_WithDefaultExample_ShouldReturnSuccessfulSearchResult() | ||
{ | ||
// Arrange | ||
string artistToSearch = "Parkway Drive"; | ||
string songToSearch = "Idols And Anchors"; | ||
ILyricsScraperClient lyricsScraperClient | ||
= new LyricsScraperClient() | ||
.WithAllProviders(); | ||
|
||
var searchRequest = new ArtistAndSongSearchRequest(artistToSearch, songToSearch); | ||
|
||
// Act | ||
var searchResult = await lyricsScraperClient.SearchLyricAsync(searchRequest); | ||
|
||
// Assert | ||
Assert.NotNull(searchResult); | ||
Assert.False(searchResult.IsEmpty()); | ||
Assert.Equal(ResponseStatusCode.Success, searchResult.ResponseStatusCode); | ||
Assert.True(string.IsNullOrEmpty(searchResult.ResponseMessage)); | ||
Assert.NotNull(searchResult.LyricText); | ||
Assert.False(searchResult.Instrumental); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.