Fixed issue #114: Args matches with optional parameters broken
This commit is contained in:
Родитель
340733cfef
Коммит
768a49a05f
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace NSubstitute.Acceptance.Specs.FieldReports
|
||||
{
|
||||
public class Issue_ArgumentCheckOfOptionalParameter
|
||||
public class Issue114_ArgumentCheckOfOptionalParameter
|
||||
{
|
||||
public interface IInterface
|
||||
{
|
||||
|
@ -10,7 +10,6 @@ namespace NSubstitute.Acceptance.Specs.FieldReports
|
|||
}
|
||||
|
||||
[Test]
|
||||
[Pending, Explicit]
|
||||
public void PassArgumentCheckForOptionalParameter()
|
||||
{
|
||||
var substitute = Substitute.For<IInterface>();
|
|
@ -76,7 +76,7 @@
|
|||
<Compile Include="FieldReports\Issue110_CustomExceptions.cs" />
|
||||
<Compile Include="FieldReports\Issue118_ConcreteClassWithPublicStaticMethod.cs" />
|
||||
<Compile Include="FieldReports\Issue111_ArgMatchesWithRefAndOutParams.cs" />
|
||||
<Compile Include="FieldReports\Issue_ArgumentCheckOfOptionalParameter.cs" />
|
||||
<Compile Include="FieldReports\Issue114_ArgumentCheckOfOptionalParameter.cs" />
|
||||
<Compile Include="PartialSubExamples.cs" />
|
||||
<Compile Include="ReturnsAndDoes.cs" />
|
||||
<Compile Include="ExceptionsWhenCheckingReceivedCalls.cs" />
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace NSubstitute.Core.Arguments
|
|||
{
|
||||
return suppliedArgumentSpecifications.Dequeue();
|
||||
}
|
||||
if (!suppliedArgumentSpecifications.AnyFor(argument, parameterInfo.ParameterType))
|
||||
if (!suppliedArgumentSpecifications.AnyFor(argument, parameterInfo.ParameterType) || parameterInfo.IsOptional)
|
||||
{
|
||||
return _argumentEqualsSpecificationFactory.Create(argument, parameterInfo.ParameterType);
|
||||
}
|
||||
|
|
|
@ -6,5 +6,6 @@ namespace NSubstitute.Core
|
|||
{
|
||||
Type ParameterType { get; }
|
||||
bool IsParams { get; }
|
||||
bool IsOptional { get; }
|
||||
}
|
||||
}
|
|
@ -20,5 +20,10 @@ namespace NSubstitute.Core
|
|||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
public bool IsOptional
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -21,5 +21,10 @@ namespace NSubstitute.Core
|
|||
{
|
||||
get { return _parameterInfo.IsParams(); }
|
||||
}
|
||||
|
||||
public bool IsOptional
|
||||
{
|
||||
get { return _parameterInfo.IsOptional; }
|
||||
}
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче