add a unit test checking whether each Command has an ApiMethodNameAttribute.

This commit is contained in:
Melvyn 2015-06-20 13:11:15 +02:00
parent a4520fb31e
commit 3aa33663b5
2 changed files with 28 additions and 0 deletions

View 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.");
}
}
}

View File

@ -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" />