File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <Project Sdk =" Microsoft.NET.Sdk" >
2+ <PropertyGroup >
3+ <TargetFramework >net8.0</TargetFramework >
4+
5+ <ImplicitUsings >enable</ImplicitUsings >
6+ <Nullable >enable</Nullable >
7+
8+ <IsPackable >false</IsPackable >
9+ <IsTestProject >true</IsTestProject >
10+ </PropertyGroup >
11+
12+ <ItemGroup >
13+ <PackageReference Include =" coverlet.collector" Version =" 6.0.0" />
14+ <PackageReference Include =" Microsoft.Extensions.Logging" Version =" 8.0.0" />
15+ <PackageReference Include =" Microsoft.Extensions.Logging.Console" Version =" 8.0.0" />
16+ <PackageReference Include =" Microsoft.NET.Test.Sdk" Version =" 17.8.0" />
17+ <PackageReference Include =" NUnit" Version =" 3.14.0" />
18+ <PackageReference Include =" NUnit.Analyzers" Version =" 3.9.0" />
19+ <PackageReference Include =" NUnit3TestAdapter" Version =" 4.5.0" />
20+ </ItemGroup >
21+
22+ <ItemGroup >
23+ <ProjectReference Include =" ..\GeniusAPI\GeniusAPI.csproj" />
24+ </ItemGroup >
25+
26+ <ItemGroup >
27+ <Using Include =" NUnit.Framework" />
28+ </ItemGroup >
29+ </Project >
Original file line number Diff line number Diff line change 1+ #pragma warning disable IDE1006 // Naming Styles
2+
3+ using GeniusAPI . Models ;
4+ using Microsoft . Extensions . Logging ;
5+ using System . Text . Json ;
6+
7+ namespace GeniusAPI . Tests ;
8+
9+ internal class Search
10+ {
11+ ILogger < LyricsClient > logger ;
12+ LyricsClient client ;
13+
14+ [ SetUp ]
15+ public void Setup ( )
16+ {
17+ ILoggerFactory factory = LoggerFactory . Create ( builder =>
18+ {
19+ builder . AddConsole ( ) ;
20+ } ) ;
21+
22+ logger = factory . CreateLogger < LyricsClient > ( ) ;
23+ client = new ( TestData . AccessToken , logger ) ;
24+ }
25+
26+
27+ [ Test ]
28+ public void search_for_tracks ( )
29+ {
30+ IEnumerable < LyricsTrack > ? tracks = null ;
31+
32+ Assert . DoesNotThrowAsync ( async ( ) =>
33+ {
34+ tracks = await client . SearchTracksAsync ( TestData . Query ) ;
35+ } ) ;
36+ Assert . That ( tracks , Is . Not . Null ) ;
37+ Assert . That ( tracks , Is . Not . Empty ) ;
38+
39+ // Output
40+ logger . LogInformation ( "\n Tracks: {tracks} " , JsonSerializer . Serialize ( tracks , TestData . SerializerOptions ) ) ;
41+ }
42+
43+
44+ [ Test ]
45+ public void fetch_track_lyrics ( )
46+ {
47+ string ? trackLyrics = null ;
48+
49+ Assert . DoesNotThrowAsync ( async ( ) =>
50+ {
51+ trackLyrics = await client . FetchLyricsAsync ( TestData . Url ) ;
52+ } ) ;
53+ Assert . That ( trackLyrics , Is . Not . Null ) ;
54+ Assert . That ( trackLyrics , Is . Not . Empty ) ;
55+
56+ // Output
57+ logger . LogInformation ( "\n Track Lyrics: {trackLyrics} " , trackLyrics ) ;
58+ }
59+ }
Original file line number Diff line number Diff line change 1+ using System . Text . Json ;
2+
3+ namespace GeniusAPI . Tests ;
4+
5+ internal class TestData
6+ {
7+ public static JsonSerializerOptions SerializerOptions = new ( )
8+ {
9+ WriteIndented = true
10+ } ;
11+
12+
13+ public const string AccessToken = "u_s2DsG-ewN4YDxgLZxzpo01mZaWSePOilc5rkBcylAYZ29cl93UzA7OEuPxWOCr" ;
14+
15+ public const string Query = "Pashanim" ;
16+
17+ public const string Url = "https://genius.com/Pashanim-shababs-botten-lyrics" ;
18+ }
You can’t perform that action at this time.
0 commit comments