mirror of
https://github.com/Sarsoo/IF.Lastfm.git
synced 2024-10-16 23:13:07 +01:00
add a unit test checking whether each Command has an ApiMethodNameAttribute.
This commit is contained in:
parent
a4520fb31e
commit
3aa33663b5
27
src/IF.Lastfm.Core.Tests/Api/LastMethodsNamesTests.cs
Normal file
27
src/IF.Lastfm.Core.Tests/Api/LastMethodsNamesTests.cs
Normal file
@ -0,0 +1,27 @@
|
||||
using IF.Lastfm.Core.Api;
|
||||
using IF.Lastfm.Core.Api.Commands;
|
||||
using IF.Lastfm.Core.Api.Helpers;
|
||||
using NUnit.Framework;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
namespace IF.Lastfm.Core.Tests.Api
|
||||
{
|
||||
|
||||
public class LastMethodsNamesTests
|
||||
{
|
||||
[Test]
|
||||
public void EnsureEachCommandHasAnApiMethodNameAttribute()
|
||||
{
|
||||
var commandBaseType = typeof(LastAsyncCommandBase);
|
||||
var allCommands = commandBaseType.Assembly.DefinedTypes
|
||||
.Where(t => t != commandBaseType && commandBaseType.IsAssignableFrom(t))
|
||||
.Where(t => t.IsClass && !t.IsAbstract);
|
||||
|
||||
var commandsWithoutAttribute = allCommands.Where(x => !x.GetCustomAttributes<ApiMethodNameAttribute>().Any());
|
||||
|
||||
Assert.IsFalse(commandsWithoutAttribute.Any(), "Warning, all commands should have anApiMethodNameAttribute.");
|
||||
}
|
||||
}
|
||||
}
|
@ -99,6 +99,7 @@
|
||||
<Compile Include="Api\Commands\UserGetRecommendedArtistsCommandTests.cs" />
|
||||
<Compile Include="Api\Commands\UserGetTopAlbumsCommandTests.cs" />
|
||||
<Compile Include="Api\Helpers\ApiHelperTests.cs" />
|
||||
<Compile Include="Api\LastMethodsNamesTests.cs" />
|
||||
<Compile Include="Api\LastAuthTests.cs" />
|
||||
<Compile Include="Api\MockAlbumApi.cs" />
|
||||
<Compile Include="MockLastFm.cs" />
|
||||
|
Loading…
Reference in New Issue
Block a user