Additional convention test were added.

This commit is contained in:
aedampir@gmail.com
2016-04-06 13:48:13 +07:00
parent 9c77ebf009
commit 3f8f782273
3 changed files with 52 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
using System;
namespace Octokit.Tests.Conventions
{
public class MissingConstructorTestClassException : Exception
{
public MissingConstructorTestClassException(Type modelType)
: base(CreateMessage(modelType))
{ }
static string CreateMessage(Type ctorTest)
{
return string.Format("Constructor test method is missing {0}.", ctorTest.FullName);
}
}
}

View File

@@ -64,6 +64,7 @@
<ItemGroup>
<Compile Include="Exception\InvalidDebuggerDisplayAttributeValueException.cs" />
<Compile Include="Exception\InvalidDebuggerDisplayReturnType.cs" />
<Compile Include="Exception\MissingConstructorTestClassException.cs" />
<Compile Include="Exception\MissingDebuggerDisplayAttributeException.cs" />
<Compile Include="Exception\MissingDebuggerDisplayPropertyException.cs" />
<Compile Include="Exception\MutableModelPropertiesException.cs" />
@@ -81,6 +82,7 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="StringExtensions.cs" />
<Compile Include="SyncObservableClients.cs" />
<Compile Include="TestConstructorTests.cs" />
<Compile Include="TypeExtensions.cs" />
</ItemGroup>
<ItemGroup>

View File

@@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Octokit.Tests.Clients;
using Xunit;
namespace Octokit.Tests.Conventions
{
public class TestConstructorTests
{
[Theory]
[MemberData("GetTestConstructorsClasses")]
public void CheckTestConstructorsNames(Type type)
{
const string constructorClassName = "TheCtor";
var classes = new HashSet<string>(type.GetNestedTypes().Select(t => t.Name));
if (!classes.Contains(constructorClassName))
{
throw new MissingConstructorTestClassException(type);
}
}
public static IEnumerable<object[]> GetTestConstructorsClasses()
{
var tests = typeof(EventsClientTests)
.Assembly
.ExportedTypes
.Where(type => type.IsClass && type.IsPublic && type.Name.EndsWith("ClientTests"))
.Select(type => new[] { type }).ToList();
return tests;
}
}
}