check for DebuggerDisplay on models

This commit is contained in:
lbargaoanu
2014-02-07 10:50:36 +02:00
parent 0c389f26a5
commit d2aff11d5c
5 changed files with 188 additions and 75 deletions
@@ -0,0 +1,38 @@
using System;
using System.Diagnostics;
using System.Linq;
using Octokit.Tests.Helpers;
using Xunit;
using Xunit.Extensions;
namespace Octokit.Tests.Conventions
{
public class DebuggerDisplayOnModels
{
[Fact]
public void CheckModelsForDebuggerDisplayAttributeExample()
{
CheckModelsForDebuggerDisplayAttribute(typeof(IAuthorizationsClient));
}
[Theory]
[ClassData(typeof(ClientInterfaces))]
public void CheckModelsForDebuggerDisplayAttribute(Type clientInterface)
{
var methods = clientInterface.GetMethods();
var modelTypes =
from modelType in
(from type in (
from method in methods from parameter in method.GetParameters() select parameter.ParameterType
).Union(
from method in methods select method.ReturnType)
select type.GetTypeInfo().Type)
where TypeExtensions.IsModel(modelType)
select modelType;
foreach(var modelType in modelTypes.Distinct())
{
AssertEx.HasAttribute<DebuggerDisplayAttribute>(modelType);
}
}
}
}