Skip to content

Commit

Permalink
#30 Added async integration tests for providers
Browse files Browse the repository at this point in the history
  • Loading branch information
skuill committed Dec 12, 2024
1 parent bd6ed76 commit 140f652
Show file tree
Hide file tree
Showing 5 changed files with 329 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
using LyricsScraperNET.Providers.Models;
using LyricsScraperNET.TestShared.Providers;
using LyricsScraperNET.UnitTest.TestModel;
using System.Threading.Tasks;
using Xunit;

namespace LyricsScraperNET.IntegrationTest.Providers.AZLyrics
{
public class AZLyricsProviderTest : ProviderTestBase
{
#region sync

[Theory]
[MemberData(nameof(GetTestData), parameters: "Providers\\AZLyrics\\lyric_test_data.json")]
public void SearchLyric_IntegrationDynamicData_Success(LyricsTestData testData)
Expand Down Expand Up @@ -49,5 +52,51 @@ public void SearchLyric_NotExistsLyrics_ShouldReturnNoDataFoundStatus(string art
Assert.True(string.IsNullOrEmpty(searchResult.ResponseMessage));
Assert.False(searchResult.Instrumental);
}

#endregion

#region async

[Theory]
[MemberData(nameof(GetTestData), parameters: "Providers\\AZLyrics\\lyric_test_data.json")]
public async Task SearchLyricAsync_IntegrationDynamicData_Success(LyricsTestData testData)
{
// Arrange
var lyricsClient = new AZLyricsProvider();
SearchRequest searchRequest = CreateSearchRequest(testData);

// Act
var searchResult = await lyricsClient.SearchLyricAsync(searchRequest);

// Assert
Assert.NotNull(searchResult);
Assert.False(searchResult.IsEmpty());
Assert.Equal(ResponseStatusCode.Success, searchResult.ResponseStatusCode);
Assert.True(string.IsNullOrEmpty(searchResult.ResponseMessage));
Assert.Equal(ExternalProviderType.AZLyrics, searchResult.ExternalProviderType);
Assert.Equal(testData.LyricResultData.Replace("\r\n", "\n"), searchResult.LyricText.Replace("\r\n", "\n"));
}

[Theory]
[InlineData("asdfasdfasdfasdf", "asdfasdfasdfasdf")]
public async Task SearchLyricAsync_NotExistsLyrics_ShouldReturnNoDataFoundStatus(string artist, string song)
{
// Arrange
var lyricsClient = new AZLyricsProvider();
var searchRequest = new ArtistAndSongSearchRequest(artist, song);

// Act
var searchResult = await lyricsClient.SearchLyricAsync(searchRequest);

// Assert
Assert.NotNull(searchResult);
Assert.True(searchResult.IsEmpty());
Assert.Equal(ResponseStatusCode.NoDataFound, searchResult.ResponseStatusCode);
Assert.Equal(ExternalProviderType.AZLyrics, searchResult.ExternalProviderType);
Assert.True(string.IsNullOrEmpty(searchResult.ResponseMessage));
Assert.False(searchResult.Instrumental);
}

#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
using LyricsScraperNET.Providers.Models;
using LyricsScraperNET.TestShared.Providers;
using LyricsScraperNET.UnitTest.TestModel;
using System.Threading.Tasks;
using Xunit;

namespace LyricsScraperNET.IntegrationTest.Providers.Genius
{
public class GeniusProviderTest : ProviderTestBase
{
#region sync

[Theory]
[MemberData(nameof(GetTestData), parameters: "Providers\\Genius\\lyric_test_data.json")]
public void SearchLyric_IntegrationDynamicData_Success(LyricsTestData testData)
Expand Down Expand Up @@ -70,5 +73,72 @@ public void SearchLyric_NotExistsLyrics_ShouldReturnNoDataFoundStatus(string art
Assert.True(string.IsNullOrEmpty(searchResult.ResponseMessage));
Assert.False(searchResult.Instrumental);
}

#endregion

#region async

[Theory]
[MemberData(nameof(GetTestData), parameters: "Providers\\Genius\\lyric_test_data.json")]
public async Task SearchLyricAsync_IntegrationDynamicData_Success(LyricsTestData testData)
{
// Arrange
var lyricsClient = new GeniusProvider();
SearchRequest searchRequest = CreateSearchRequest(testData);

// Act
var searchResult = await lyricsClient.SearchLyricAsync(searchRequest);

// Assert
Assert.NotNull(searchResult);
Assert.False(searchResult.IsEmpty());
Assert.Equal(ResponseStatusCode.Success, searchResult.ResponseStatusCode);
Assert.True(string.IsNullOrEmpty(searchResult.ResponseMessage));
Assert.Equal(ExternalProviderType.Genius, searchResult.ExternalProviderType);
Assert.Equal(testData.LyricResultData.Replace("\r\n", "\n"), searchResult.LyricText.Replace("\r\n", "\n"));
Assert.False(searchResult.Instrumental);
}

[Theory]
[MemberData(nameof(GetTestData), parameters: "Providers\\Genius\\instrumental_test_data.json")]
public async Task SearchLyricAsync_UnitDynamicData_Instrumental(LyricsTestData testData)
{
// Arrange
var lyricsClient = new GeniusProvider();
SearchRequest searchRequest = CreateSearchRequest(testData);

// Act
var searchResult = await lyricsClient.SearchLyricAsync(searchRequest);

// Assert
Assert.NotNull(searchResult);
Assert.True(searchResult.IsEmpty());
Assert.Equal(ResponseStatusCode.Success, searchResult.ResponseStatusCode);
Assert.True(string.IsNullOrEmpty(searchResult.ResponseMessage));
Assert.Equal(ExternalProviderType.Genius, searchResult.ExternalProviderType);
Assert.True(searchResult.Instrumental);
}

[Theory]
[InlineData("asdfasdfasdfasdf", "asdfasdfasdfasdf")]
public async Task SearchLyricAsync_NotExistsLyrics_ShouldReturnNoDataFoundStatus(string artist, string song)
{
// Arrange
var lyricsClient = new GeniusProvider();
var searchRequest = new ArtistAndSongSearchRequest(artist, song);

// Act
var searchResult = await lyricsClient.SearchLyricAsync(searchRequest);

// Assert
Assert.NotNull(searchResult);
Assert.True(searchResult.IsEmpty());
Assert.Equal(ResponseStatusCode.NoDataFound, searchResult.ResponseStatusCode);
Assert.Equal(ExternalProviderType.Genius, searchResult.ExternalProviderType);
Assert.True(string.IsNullOrEmpty(searchResult.ResponseMessage));
Assert.False(searchResult.Instrumental);
}

#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
using LyricsScraperNET.Providers.Models;
using LyricsScraperNET.TestShared.Providers;
using LyricsScraperNET.UnitTest.TestModel;
using System.Threading.Tasks;
using Xunit;

namespace LyricsScraperNET.IntegrationTest.Providers.LyricFind
{
public class LyricFindProviderTest : ProviderTestBase
{
#region sync

[Theory]
[MemberData(nameof(GetTestData), parameters: "Providers\\LyricFind\\lyric_test_data.json")]
public void SearchLyric_IntegrationDynamicData_Success(LyricsTestData testData)
Expand Down Expand Up @@ -70,5 +73,72 @@ public void SearchLyric_NotExistsLyrics_ShouldReturnNoDataFoundStatus(string art
Assert.True(string.IsNullOrEmpty(searchResult.ResponseMessage));
Assert.False(searchResult.Instrumental);
}

#endregion

#region async

[Theory]
[MemberData(nameof(GetTestData), parameters: "Providers\\LyricFind\\lyric_test_data.json")]
public async Task SearchLyricAsync_IntegrationDynamicData_Success(LyricsTestData testData)
{
// Arrange
var lyricsClient = new LyricFindProvider();
SearchRequest searchRequest = CreateSearchRequest(testData);

// Act
var searchResult = await lyricsClient.SearchLyricAsync(searchRequest);

// Assert
Assert.NotNull(searchResult);
Assert.False(searchResult.IsEmpty());
Assert.Equal(ResponseStatusCode.Success, searchResult.ResponseStatusCode);
Assert.True(string.IsNullOrEmpty(searchResult.ResponseMessage));
Assert.Equal(ExternalProviderType.LyricFind, searchResult.ExternalProviderType);
Assert.Equal(testData.LyricResultData.Replace("\r\n", "\n"), searchResult.LyricText.Replace("\r\n", "\n"));
Assert.False(searchResult.Instrumental);
}

[Theory]
[MemberData(nameof(GetTestData), parameters: "Providers\\LyricFind\\instrumental_test_data.json")]
public async Task SearchLyricAsync_IntegrationDynamicData_Instrumental(LyricsTestData testData)
{
// Arrange
var lyricsClient = new LyricFindProvider();
SearchRequest searchRequest = CreateSearchRequest(testData);

// Act
var searchResult = await lyricsClient.SearchLyricAsync(searchRequest);

// Assert
Assert.NotNull(searchResult);
Assert.True(searchResult.IsEmpty());
Assert.Equal(ResponseStatusCode.Success, searchResult.ResponseStatusCode);
Assert.True(string.IsNullOrEmpty(searchResult.ResponseMessage));
Assert.Equal(ExternalProviderType.LyricFind, searchResult.ExternalProviderType);
Assert.True(searchResult.Instrumental);
}

[Theory]
[InlineData("asdfasdfasdfasdf", "asdfasdfasdfasdf")]
public async Task SearchLyricAsync_NotExistsLyrics_ShouldReturnNoDataFoundStatus(string artist, string song)
{
// Arrange
var lyricsClient = new LyricFindProvider();
var searchRequest = new ArtistAndSongSearchRequest(artist, song);

// Act
var searchResult = await lyricsClient.SearchLyricAsync(searchRequest);

// Assert
Assert.NotNull(searchResult);
Assert.True(searchResult.IsEmpty());
Assert.Equal(ResponseStatusCode.NoDataFound, searchResult.ResponseStatusCode);
Assert.Equal(ExternalProviderType.LyricFind, searchResult.ExternalProviderType);
Assert.True(string.IsNullOrEmpty(searchResult.ResponseMessage));
Assert.False(searchResult.Instrumental);
}

#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
using LyricsScraperNET.Providers.Musixmatch;
using LyricsScraperNET.TestShared.Providers;
using LyricsScraperNET.UnitTest.TestModel;
using System.Threading.Tasks;
using Xunit;

namespace LyricsScraperNET.IntegrationTest.Providers.Musixmatch
{
public class MusixmatchProviderTest : ProviderTestBase
{
#region sync

[Theory]
[MemberData(nameof(GetTestData), parameters: "Providers\\Musixmatch\\lyric_test_data.json")]
public void SearchLyric_IntegrationDynamicData_Success(LyricsTestData testData)
Expand Down Expand Up @@ -70,5 +73,72 @@ public void SearchLyric_NotExistsLyrics_ShouldReturnNoDataFoundStatus(string art
Assert.True(string.IsNullOrEmpty(searchResult.ResponseMessage));
Assert.False(searchResult.Instrumental);
}

#endregion

#region async

[Theory]
[MemberData(nameof(GetTestData), parameters: "Providers\\Musixmatch\\lyric_test_data.json")]
public async Task SearchLyricAsync_IntegrationDynamicData_Success(LyricsTestData testData)
{
// Arrange
var lyricsClient = new MusixmatchProvider();
SearchRequest searchRequest = CreateSearchRequest(testData);

// Act
var searchResult = await lyricsClient.SearchLyricAsync(searchRequest);

// Assert
Assert.NotNull(searchResult);
Assert.False(searchResult.IsEmpty());
Assert.Equal(ResponseStatusCode.Success, searchResult.ResponseStatusCode);
Assert.True(string.IsNullOrEmpty(searchResult.ResponseMessage));
Assert.Equal(ExternalProviderType.Musixmatch, searchResult.ExternalProviderType);
Assert.Equal(testData.LyricResultData.Replace("\r\n", "\n"), searchResult.LyricText);
Assert.False(searchResult.Instrumental);
}

[Theory]
[MemberData(nameof(GetTestData), parameters: "Providers\\Musixmatch\\instrumental_test_data.json")]
public async Task SearchLyricAsync_IntegrationDynamicData_Instrumental(LyricsTestData testData)
{
// Arrange
var lyricsClient = new MusixmatchProvider();
SearchRequest searchRequest = CreateSearchRequest(testData);

// Act
var searchResult = await lyricsClient.SearchLyricAsync(searchRequest);

// Assert
Assert.NotNull(searchResult);
Assert.True(searchResult.IsEmpty());
Assert.Equal(ResponseStatusCode.Success, searchResult.ResponseStatusCode);
Assert.True(string.IsNullOrEmpty(searchResult.ResponseMessage));
Assert.Equal(ExternalProviderType.Musixmatch, searchResult.ExternalProviderType);
Assert.True(searchResult.Instrumental);
}

[Theory]
[InlineData("asdfasdfasdfasdf", "asdfasdfasdfasdf")]
public async Task SearchLyricAsync_NotExistsLyrics_ShouldReturnNoDataFoundStatus(string artist, string song)
{
// Arrange
var lyricsClient = new MusixmatchProvider();
var searchRequest = new ArtistAndSongSearchRequest(artist, song);

// Act
var searchResult = await lyricsClient.SearchLyricAsync(searchRequest);

// Assert
Assert.NotNull(searchResult);
Assert.True(searchResult.IsEmpty());
Assert.Equal(ResponseStatusCode.NoDataFound, searchResult.ResponseStatusCode);
Assert.Equal(ExternalProviderType.Musixmatch, searchResult.ExternalProviderType);
Assert.True(string.IsNullOrEmpty(searchResult.ResponseMessage));
Assert.False(searchResult.Instrumental);
}

#endregion
}
}
Loading

0 comments on commit 140f652

Please sign in to comment.