mirror of
https://github.com/zoriya/octokit.net.git
synced 2025-12-06 07:16:09 +00:00
Additional convention test were added.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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>
|
||||
|
||||
34
Octokit.Tests.Conventions/TestConstructorTests.cs
Normal file
34
Octokit.Tests.Conventions/TestConstructorTests.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user