Skip to content

Commit

Permalink
Fix for 31. Not picking up ambiguous arg matchers properly
Browse files Browse the repository at this point in the history
Update SuppliedArgumentSpecifications to return AnyFor correctly if object
has already been removed.
  • Loading branch information
AnthonyEgerton committed Oct 14, 2010
1 parent 72be8ee commit 8d8aebf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
1 change: 0 additions & 1 deletion Source/NSubstitute.Acceptance.Specs/ParameterMatching.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ public void Received_should_compare_elements_for_params_arguments()
}

[Test]
[Pending]
public void Throw_with_ambiguous_arguments_when_given_an_arg_matcher_and_a_default_arg_value()
{
Assert.Throws<AmbiguousArgumentsException>(() =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ public void AnyFor_should_return_true()
Assert.That(sut.AnyFor(Type3), Is.True);
}

[Test]
public void AnyFor_should_return_true_after_items_removed()
{
sut.DequeueAll();
Assert.That(sut.AnyFor(Type3), Is.True);
}

[Test]
public void AnyFor_should_return_false()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@ namespace NSubstitute.Core.Arguments
public class SuppliedArgumentSpecifications : ISuppliedArgumentSpecifications
{
private readonly Queue<IArgumentSpecification> _queue;
private readonly List<IArgumentSpecification> _list;

public SuppliedArgumentSpecifications(IEnumerable<IArgumentSpecification> argumentSpecifications)
{
_queue = new Queue<IArgumentSpecification>(argumentSpecifications);
_list = new List<IArgumentSpecification>(argumentSpecifications);
_queue = new Queue<IArgumentSpecification>(_list);
}

public bool AnyFor(Type type)
{
return _queue.Any(x => x.ForType == type);
return _list.Any(x => x.ForType == type);
}

public bool NextFor(Type type)
Expand Down

0 comments on commit 8d8aebf

Please sign in to comment.