-
-
Notifications
You must be signed in to change notification settings - Fork 802
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #908 from stakx/generic-type-argument-matchers
Add support for generic type argument matchers (It.IsAnyType and friends)
- Loading branch information
Showing
39 changed files
with
1,325 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
// Copyright (c) 2007, Clarius Consulting, Manas Technology Solutions, InSTEDD. | ||
// All rights reserved. Licensed under the BSD 3-Clause License; see License.txt. | ||
|
||
using System; | ||
|
||
namespace Moq | ||
{ | ||
internal interface IMatcher | ||
{ | ||
bool Matches(object value); | ||
bool Matches(object argument, Type parameterType); | ||
|
||
void SetupEvaluatedSuccessfully(object value); | ||
void SetupEvaluatedSuccessfully(object argument, Type parameterType); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using System; | ||
|
||
namespace Moq | ||
{ | ||
/// <summary> | ||
/// Types that implement this interface represent a criterion against which generic type arguments are matched. | ||
/// <para> | ||
/// To be used in combination with <see cref="TypeMatcherAttribute"/>. | ||
/// </para> | ||
/// </summary> | ||
public interface ITypeMatcher | ||
{ | ||
/// <summary> | ||
/// Matches the provided type argument against the criterion represented by this type matcher. | ||
/// </summary> | ||
/// <param name="typeArgument"> | ||
/// The generic type argument that should be matched. | ||
/// </param> | ||
/// <returns> | ||
/// <see langword="true"/> if the provided type argument matched the criterion represented by this instance; | ||
/// otherwise, <see langword="false"/>. | ||
/// </returns> | ||
bool Matches(Type typeArgument); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright (c) 2007, Clarius Consulting, Manas Technology Solutions, InSTEDD. | ||
// All rights reserved. Licensed under the BSD 3-Clause License; see License.txt. | ||
|
||
using System; | ||
|
||
namespace Moq | ||
{ | ||
/// <summary> | ||
/// A delegate-like type for use with `setup.Callback` which instructs the `Callback` verb | ||
/// to provide the callback with the current <see cref="IInvocation"/>, instead of | ||
/// with a list of arguments. | ||
/// <para> | ||
/// This type is useful in scenarios involving generic type argument matchers (such as | ||
/// <see cref="It.IsAnyType" />) as <see cref="IInvocation"/> allows the discovery of both | ||
/// arguments and type arguments. | ||
/// </para> | ||
/// </summary> | ||
public readonly struct InvocationAction | ||
{ | ||
internal readonly Action<IInvocation> Action; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="InvocationAction"/> type. | ||
/// </summary> | ||
/// <param name="action">The delegate that should be wrapped by this instance.</param> | ||
public InvocationAction(Action<IInvocation> action) | ||
{ | ||
this.Action = action; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright (c) 2007, Clarius Consulting, Manas Technology Solutions, InSTEDD. | ||
// All rights reserved. Licensed under the BSD 3-Clause License; see License.txt. | ||
|
||
using System; | ||
|
||
namespace Moq | ||
{ | ||
/// <summary> | ||
/// A delegate-like type for use with `setup.Returns` which instructs the `Returns` verb | ||
/// to provide the callback with the current <see cref="IInvocation"/>, instead of | ||
/// with a list of arguments. | ||
/// <para> | ||
/// This type is useful in scenarios involving generic type argument matchers (such as | ||
/// <see cref="It.IsAnyType" />) as <see cref="IInvocation"/> allows the discovery of both | ||
/// arguments and type arguments. | ||
/// </para> | ||
/// </summary> | ||
public readonly struct InvocationFunc | ||
{ | ||
internal readonly Func<IInvocation, object> Func; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="InvocationFunc"/> type. | ||
/// </summary> | ||
/// <param name="func">The delegate that should be wrapped by this instance.</param> | ||
public InvocationFunc(Func<IInvocation, object> func) | ||
{ | ||
this.Func = func; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.