mirror of
https://github.com/Sarsoo/IF.Lastfm.git
synced 2024-10-17 07:13:09 +01:00
Add tests to TagApi.GetInfoCommand
This commit is contained in:
parent
71a87cdb42
commit
1fa98d41ee
@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using IF.Lastfm.Core.Api.Commands.Tag;
|
||||
using IF.Lastfm.Core.Api.Enums;
|
||||
using IF.Lastfm.Core.Objects;
|
||||
using IF.Lastfm.Core.Tests.Resources;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace IF.Lastfm.Core.Tests.Api.Commands.Tag
|
||||
{
|
||||
public class GetInfoCommandTests: CommandTestsBase
|
||||
{
|
||||
[Test]
|
||||
public async Task HandleSuccessResponse()
|
||||
{
|
||||
//Arrange
|
||||
const string tagName = "disco";
|
||||
const string tagUri = "http://www.last.fm/tag/disco";
|
||||
|
||||
var command = new GetInfoCommand(MAuth.Object, tagName);
|
||||
var expectedTag=new LastTag(tagName,tagUri)
|
||||
{
|
||||
Reach = 34671,
|
||||
Streamable = true
|
||||
};
|
||||
|
||||
|
||||
//Act
|
||||
var response = CreateResponseMessage(Encoding.UTF8.GetString(TagApiResponses.GetInfoSuccess));
|
||||
var lastResponse = await command.HandleResponse(response);
|
||||
var tag = lastResponse.Content;
|
||||
|
||||
//Assert
|
||||
Assert.IsTrue(lastResponse.Success);
|
||||
Assert.AreEqual(expectedTag.Reach,tag.Reach);
|
||||
Assert.AreEqual(expectedTag.Name, tag.Name);
|
||||
Assert.AreEqual(expectedTag.Streamable, tag.Streamable);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task HandleErrorResponse()
|
||||
{
|
||||
var command = new GetInfoCommand(MAuth.Object, "errorTag");
|
||||
|
||||
var response = CreateResponseMessage(Encoding.UTF8.GetString(TagApiResponses.GetInfoError));
|
||||
|
||||
var parsed = await command.HandleResponse(response);
|
||||
|
||||
Assert.IsFalse(parsed.Success);
|
||||
Assert.IsTrue(parsed.Status == LastResponseStatus.MissingParameters);
|
||||
}
|
||||
}
|
||||
}
|
@ -92,6 +92,7 @@
|
||||
<Compile Include="Api\Commands\Library\LibraryGetTracksCommandTests.cs" />
|
||||
<Compile Include="Api\Commands\Library\RemoveScrobbleCommandTests.cs" />
|
||||
<Compile Include="Api\Commands\Library\RemoveTrackCommandTests.cs" />
|
||||
<Compile Include="Api\Commands\Tag\GetInfoCommandTests.cs" />
|
||||
<Compile Include="Api\Commands\Tag\GetSimilarCommandTests.cs" />
|
||||
<Compile Include="Api\Commands\TrackApi\GetTrackShoutsCommandTests.cs" />
|
||||
<Compile Include="Api\Commands\ArtistGetInfoCommandTests.cs" />
|
||||
|
Loading…
Reference in New Issue
Block a user