mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-06 03:55:55 +00:00
add convention test to ensure all response models have a public parameterless ctor
2 model classes were missing one - technically not needed for these 2 classes due to their api calls being basic data types that then get populated into these objects, but it's easiest to just add them to these 2 classes so the test can pass on all response models
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
using System;
|
||||
|
||||
namespace Octokit.Tests.Conventions
|
||||
{
|
||||
public class MissingPublicParameterlessCtorException : Exception
|
||||
{
|
||||
public MissingPublicParameterlessCtorException(Type modelType)
|
||||
: base(string.Format("Model type '{0}' is missing a Public Parameterless Constructor required by SimpleJson Deserializer.", modelType.FullName))
|
||||
{ }
|
||||
}
|
||||
}
|
||||
@@ -37,6 +37,18 @@ namespace Octokit.Tests.Conventions
|
||||
}
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[MemberData("ResponseModelTypes")]
|
||||
public void AllResponseModelsHavePublicParameterlessCtors(Type modelType)
|
||||
{
|
||||
var ctor = modelType.GetConstructor(Type.EmptyTypes);
|
||||
|
||||
if (ctor == null || !ctor.IsPublic)
|
||||
{
|
||||
throw new MissingPublicParameterlessCtorException(modelType);
|
||||
}
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[MemberData("ResponseModelTypes")]
|
||||
public void ResponseModelsHaveGetterOnlyProperties(Type modelType)
|
||||
|
||||
@@ -67,6 +67,7 @@
|
||||
<Compile Include="Exception\MissingClientConstructorTestClassException.cs" />
|
||||
<Compile Include="Exception\MissingClientConstructorTestMethodException.cs" />
|
||||
<Compile Include="Exception\MissingDebuggerDisplayAttributeException.cs" />
|
||||
<Compile Include="Exception\MissingPublicParameterlessCtorException.cs" />
|
||||
<Compile Include="Exception\MissingDebuggerDisplayPropertyException.cs" />
|
||||
<Compile Include="Exception\MutableModelPropertiesException.cs" />
|
||||
<Compile Include="Exception\PaginationGetAllMethodNameMismatchException.cs" />
|
||||
|
||||
@@ -10,6 +10,9 @@ namespace Octokit
|
||||
[DebuggerDisplay("{DebuggerDisplay,nq}")]
|
||||
public class PunchCard
|
||||
{
|
||||
public PunchCard()
|
||||
{ }
|
||||
|
||||
public PunchCard(IEnumerable<IList<int>> punchCardData)
|
||||
{
|
||||
Ensure.ArgumentNotNull(punchCardData, "punchCardData");
|
||||
|
||||
@@ -7,6 +7,9 @@ namespace Octokit
|
||||
[DebuggerDisplay("{DebuggerDisplay,nq}")]
|
||||
public class RepositoryLanguage
|
||||
{
|
||||
public RepositoryLanguage()
|
||||
{ }
|
||||
|
||||
public RepositoryLanguage(string name, long numberOfBytes)
|
||||
{
|
||||
Name = name;
|
||||
|
||||
Reference in New Issue
Block a user