diff --git a/Source/Mockolate.SourceGenerators/Sources/Sources.MethodSetups.cs b/Source/Mockolate.SourceGenerators/Sources/Sources.MethodSetups.cs
index 95dce0c9..705f992f 100644
--- a/Source/Mockolate.SourceGenerators/Sources/Sources.MethodSetups.cs
+++ b/Source/Mockolate.SourceGenerators/Sources/Sources.MethodSetups.cs
@@ -110,8 +110,10 @@ private static void AppendVoidMethodSetup(StringBuilder sb, int numberOfParamete
string parameters = string.Join(", ", Enumerable.Range(1, numberOfParameters).Select(i => $"p{i}"));
string discards = string.Join(", ", Enumerable.Range(1, numberOfParameters).Select(_ => "_"));
- sb.AppendXmlSummary($"Sets up a method with {numberOfParameters} parameters {GetTypeParametersDescription(numberOfParameters)} returning .", "\t");
- sb.Append("\tinternal interface IVoidMethodSetup<").Append(typeParams).Append(">").AppendLine();
+ sb.AppendXmlSummary(
+ $"Sets up a method with {numberOfParameters} parameters {GetTypeParametersDescription(numberOfParameters)} returning .",
+ "\t");
+ sb.Append("\tinternal interface IVoidMethodSetup<").Append(typeParams).Append("> : IMethodSetup").AppendLine();
sb.Append("\t{").AppendLine();
sb.AppendXmlSummary("Specifies if calling the base class implementation should be skipped.");
sb.AppendXmlRemarks("If not specified, use .");
@@ -150,32 +152,40 @@ private static void AppendVoidMethodSetup(StringBuilder sb, int numberOfParamete
.AppendLine();
sb.AppendLine();
- sb.AppendXmlSummary("Registers a that will calculate the exception to throw when the method is invoked.");
+ sb.AppendXmlSummary(
+ "Registers a that will calculate the exception to throw when the method is invoked.");
sb.Append("\t\tIVoidMethodSetupReturnBuilder<").Append(typeParams).Append("> Throws(Func<")
.Append(typeParams).Append(", Exception> callback);").AppendLine();
sb.AppendLine();
- sb.AppendXmlSummary("Registers a that will calculate the exception to throw when the method is invoked.");
+ sb.AppendXmlSummary(
+ "Registers a that will calculate the exception to throw when the method is invoked.");
sb.Append("\t\tIVoidMethodSetupReturnBuilder<").Append(typeParams).Append("> Throws(Func callback);")
.AppendLine();
sb.Append("}").AppendLine();
sb.AppendLine();
- sb.AppendXmlSummary($"Sets up a callback for a method with {numberOfParameters} parameters {GetTypeParametersDescription(numberOfParameters)} returning .", "");
+ sb.AppendXmlSummary(
+ $"Sets up a callback for a method with {numberOfParameters} parameters {GetTypeParametersDescription(numberOfParameters)} returning .",
+ "");
sb.Append("internal interface IVoidMethodSetupCallbackBuilder<").Append(typeParams)
.Append("> : IVoidMethodSetupCallbackWhenBuilder<").Append(typeParams).Append(">").AppendLine();
sb.Append("{").AppendLine();
sb.AppendXmlSummary("Runs the callback in parallel to the other callbacks.");
sb.Append("\t\tIVoidMethodSetupCallbackBuilder<").Append(typeParams).Append("> InParallel();").AppendLine();
sb.AppendLine();
- sb.AppendXmlSummary("Limits the callback to only execute for method invocations where the predicate returns true.");
- sb.AppendXmlRemarks("Provides a zero-based counter indicating how many times the method has been invoked so far.");
+ sb.AppendXmlSummary(
+ "Limits the callback to only execute for method invocations where the predicate returns true.");
+ sb.AppendXmlRemarks(
+ "Provides a zero-based counter indicating how many times the method has been invoked so far.");
sb.Append("\t\tIVoidMethodSetupCallbackWhenBuilder<").Append(typeParams)
.Append("> When(Func predicate);").AppendLine();
sb.Append("}").AppendLine();
sb.AppendLine();
- sb.AppendXmlSummary($"Sets up a when callback for a method with {numberOfParameters} parameters {GetTypeParametersDescription(numberOfParameters)} returning .", "");
+ sb.AppendXmlSummary(
+ $"Sets up a when callback for a method with {numberOfParameters} parameters {GetTypeParametersDescription(numberOfParameters)} returning .",
+ "");
sb.Append("internal interface IVoidMethodSetupCallbackWhenBuilder<").Append(typeParams)
.Append("> : IVoidMethodSetup<").Append(typeParams).Append(">").AppendLine();
sb.Append("{").AppendLine();
@@ -201,18 +211,24 @@ private static void AppendVoidMethodSetup(StringBuilder sb, int numberOfParamete
sb.AppendLine();
- sb.AppendXmlSummary($"Sets up a return callback for a method with {numberOfParameters} parameters {GetTypeParametersDescription(numberOfParameters)} returning .", "");
+ sb.AppendXmlSummary(
+ $"Sets up a return callback for a method with {numberOfParameters} parameters {GetTypeParametersDescription(numberOfParameters)} returning .",
+ "");
sb.Append("internal interface IVoidMethodSetupReturnBuilder<").Append(typeParams)
.Append("> : IVoidMethodSetupReturnWhenBuilder<").Append(typeParams).Append(">").AppendLine();
sb.Append("{").AppendLine();
- sb.AppendXmlSummary("Limits the throw to only execute for method invocations where the predicate returns true.");
- sb.AppendXmlRemarks("Provides a zero-based counter indicating how many times the method has been invoked so far.");
+ sb.AppendXmlSummary(
+ "Limits the throw to only execute for method invocations where the predicate returns true.");
+ sb.AppendXmlRemarks(
+ "Provides a zero-based counter indicating how many times the method has been invoked so far.");
sb.Append("\t\tIVoidMethodSetupReturnWhenBuilder<").Append(typeParams)
.Append("> When(Func predicate);").AppendLine();
sb.Append("}").AppendLine();
sb.AppendLine();
- sb.AppendXmlSummary($"Sets up a when return callback for a method with {numberOfParameters} parameters {GetTypeParametersDescription(numberOfParameters)} returning .", "");
+ sb.AppendXmlSummary(
+ $"Sets up a when return callback for a method with {numberOfParameters} parameters {GetTypeParametersDescription(numberOfParameters)} returning .",
+ "");
sb.Append("internal interface IVoidMethodSetupReturnWhenBuilder<").Append(typeParams)
.Append("> : IVoidMethodSetup<").Append(typeParams).Append(">").AppendLine();
sb.Append("{").AppendLine();
@@ -236,7 +252,9 @@ private static void AppendVoidMethodSetup(StringBuilder sb, int numberOfParamete
sb.Append("}").AppendLine();
sb.AppendLine();
- sb.AppendXmlSummary($"Sets up a method with {numberOfParameters} parameters {GetTypeParametersDescription(numberOfParameters)} returning .", "");
+ sb.AppendXmlSummary(
+ $"Sets up a method with {numberOfParameters} parameters {GetTypeParametersDescription(numberOfParameters)} returning .",
+ "");
sb.Append("internal class VoidMethodSetup<").Append(typeParams)
.Append("> : MethodSetup,").AppendLine();
sb.Append("\t\tIVoidMethodSetupCallbackBuilder<").Append(typeParams).Append(">,").AppendLine();
@@ -272,6 +290,9 @@ private static void AppendVoidMethodSetup(StringBuilder sb, int numberOfParamete
}
sb.Append(')').AppendLine();
+ sb.Append("\t\t\t: base(new MethodParameterMatch(name, [")
+ .Append(string.Join(", ", Enumerable.Range(1, numberOfParameters).Select(i => $"match{i}"))).Append("]))")
+ .AppendLine();
sb.Append("\t\t{").AppendLine();
sb.Append("\t\t\t_name = name;").AppendLine();
for (int i = 1; i <= numberOfParameters; i++)
@@ -286,12 +307,13 @@ private static void AppendVoidMethodSetup(StringBuilder sb, int numberOfParamete
.Append(string.Join(", ", Enumerable.Range(1, numberOfParameters).Select(i => $"T{i}"))).Append("}\" />")
.AppendLine();
sb.Append("\t\tpublic VoidMethodSetup(string name, IParameters matches)").AppendLine();
+ sb.Append("\t\t\t: base(new MethodParametersMatch(name, matches))").AppendLine();
sb.Append("\t\t{").AppendLine();
sb.Append("\t\t\t_name = name;").AppendLine();
sb.Append("\t\t\t_matches = matches;").AppendLine();
sb.Append("\t\t}").AppendLine();
sb.AppendLine();
-
+
sb.AppendXmlSummary("Specifies if calling the base class implementation should be skipped.");
sb.AppendXmlRemarks("If not specified, use .");
sb.Append("\t\tpublic IVoidMethodSetup<").Append(typeParams)
@@ -381,7 +403,8 @@ private static void AppendVoidMethodSetup(StringBuilder sb, int numberOfParamete
sb.Append("\t\t}").AppendLine();
sb.AppendLine();
- sb.AppendXmlSummary("Registers a that will calculate the exception to throw when the method is invoked.");
+ sb.AppendXmlSummary(
+ "Registers a that will calculate the exception to throw when the method is invoked.");
sb.Append("\t\tpublic IVoidMethodSetupReturnBuilder<").Append(typeParams).Append("> Throws(Func<")
.Append(typeParams).Append(", Exception> callback)").AppendLine();
sb.Append("\t\t{").AppendLine();
@@ -393,7 +416,8 @@ private static void AppendVoidMethodSetup(StringBuilder sb, int numberOfParamete
sb.Append("\t\t}").AppendLine();
sb.AppendLine();
- sb.AppendXmlSummary("Registers a that will calculate the exception to throw when the method is invoked.");
+ sb.AppendXmlSummary(
+ "Registers a that will calculate the exception to throw when the method is invoked.");
sb.Append("\t\tpublic IVoidMethodSetupReturnBuilder<").Append(typeParams)
.Append("> Throws(Func callback)")
.AppendLine();
@@ -549,16 +573,6 @@ private static void AppendVoidMethodSetup(StringBuilder sb, int numberOfParamete
.AppendLine();
sb.AppendLine();
- sb.Append("\t\t/// ").AppendLine();
- sb.Append("\t\tprotected override bool IsMatch(MethodInvocation invocation)").AppendLine();
- sb.Append("\t\t\t=> invocation.Name.Equals(_name) &&").AppendLine();
- sb.Append("\t\t\t\t(_matches is not null").AppendLine();
- sb.Append("\t\t\t\t\t? _matches.Matches(invocation.Parameters)").AppendLine();
- sb.Append("\t\t\t\t\t: Matches([")
- .Append(string.Join(", ", Enumerable.Range(1, numberOfParameters).Select(x => $"_match{x}!")))
- .Append("], invocation.Parameters));").AppendLine();
- sb.AppendLine();
-
sb.Append("\t\t/// ").AppendLine();
sb.Append("\t\tprotected override void TriggerParameterCallbacks(object?[] parameters)").AppendLine();
sb.Append("\t\t\t=> TriggerCallbacks([")
@@ -629,8 +643,10 @@ private static void AppendReturnMethodSetup(StringBuilder sb, int numberOfParame
string parameters = string.Join(", ", Enumerable.Range(1, numberOfParameters).Select(i => $"p{i}"));
string discards = string.Join(", ", Enumerable.Range(1, numberOfParameters).Select(_ => "_"));
- sb.AppendXmlSummary($"Sets up a method with {numberOfParameters} parameters {GetTypeParametersDescription(numberOfParameters)} returning .", "\t");
- sb.Append("\tinternal interface IReturnMethodSetup")
+ sb.AppendXmlSummary(
+ $"Sets up a method with {numberOfParameters} parameters {GetTypeParametersDescription(numberOfParameters)} returning .",
+ "\t");
+ sb.Append("\tinternal interface IReturnMethodSetup : IMethodSetup")
.AppendLine();
sb.Append("\t{").AppendLine();
sb.AppendXmlSummary("Specifies if calling the base class implementation should be skipped.");
@@ -683,18 +699,22 @@ private static void AppendReturnMethodSetup(StringBuilder sb, int numberOfParame
.AppendLine();
sb.AppendLine();
- sb.AppendXmlSummary("Registers a that will calculate the exception to throw when the method is invoked.");
+ sb.AppendXmlSummary(
+ "Registers a that will calculate the exception to throw when the method is invoked.");
sb.Append("\t\tIReturnMethodSetupReturnBuilder Throws(Func<")
.Append(typeParams).Append(", Exception> callback);").AppendLine();
sb.AppendLine();
- sb.AppendXmlSummary("Registers a that will calculate the exception to throw when the method is invoked.");
+ sb.AppendXmlSummary(
+ "Registers a that will calculate the exception to throw when the method is invoked.");
sb.Append("\t\tIReturnMethodSetupReturnBuilder Throws(Func callback);").AppendLine();
sb.Append("\t}").AppendLine();
sb.AppendLine();
- sb.AppendXmlSummary($"Sets up a callback for a method with {numberOfParameters} parameters {GetTypeParametersDescription(numberOfParameters)} returning .", "\t");
+ sb.AppendXmlSummary(
+ $"Sets up a callback for a method with {numberOfParameters} parameters {GetTypeParametersDescription(numberOfParameters)} returning .",
+ "\t");
sb.Append("\tinternal interface IReturnMethodSetupCallbackBuilder : IReturnMethodSetupCallbackWhenBuilder")
.AppendLine();
@@ -703,63 +723,79 @@ private static void AppendReturnMethodSetup(StringBuilder sb, int numberOfParame
sb.Append("\t\tIReturnMethodSetupCallbackBuilder InParallel();")
.AppendLine();
sb.AppendLine();
-
- sb.AppendXmlSummary("Limits the callback to only execute for method invocations where the predicate returns true.");
- sb.AppendXmlRemarks("Provides a zero-based counter indicating how many times the method has been invoked so far.");
+
+ sb.AppendXmlSummary(
+ "Limits the callback to only execute for method invocations where the predicate returns true.");
+ sb.AppendXmlRemarks(
+ "Provides a zero-based counter indicating how many times the method has been invoked so far.");
sb.Append("\t\tIReturnMethodSetupCallbackWhenBuilder When(Func predicate);").AppendLine();
sb.Append("\t}").AppendLine();
sb.AppendLine();
-
- sb.AppendXmlSummary($"Sets up a when callback for a method with {numberOfParameters} parameters {GetTypeParametersDescription(numberOfParameters)} returning .", "\t");
+
+ sb.AppendXmlSummary(
+ $"Sets up a when callback for a method with {numberOfParameters} parameters {GetTypeParametersDescription(numberOfParameters)} returning .",
+ "\t");
sb.Append("\tinternal interface IReturnMethodSetupCallbackWhenBuilder : IReturnMethodSetup")
.AppendLine();
sb.Append("\t{").AppendLine();
-
+
sb.AppendXmlSummary("Repeats the callback for the given number of .");
- sb.AppendXmlRemarks($"The number of times is only counted for actual executions ( evaluates to ).");
+ sb.AppendXmlRemarks(
+ $"The number of times is only counted for actual executions ( evaluates to ).");
sb.Append("\t\tIReturnMethodSetupCallbackWhenBuilder For(int times);")
.AppendLine();
sb.AppendLine();
-
+
sb.AppendXmlSummary("Deactivates the callback after the given number of .");
- sb.AppendXmlRemarks($"The number of times is only counted for actual executions ( evaluates to ).");
+ sb.AppendXmlRemarks(
+ $"The number of times is only counted for actual executions ( evaluates to ).");
sb.Append("\t\tIReturnMethodSetup Only(int times);").AppendLine();
sb.Append("\t}").AppendLine();
sb.AppendLine();
- sb.AppendXmlSummary($"Sets up a return callback for a method with {numberOfParameters} parameters {GetTypeParametersDescription(numberOfParameters)} returning .", "\t");
+ sb.AppendXmlSummary(
+ $"Sets up a return callback for a method with {numberOfParameters} parameters {GetTypeParametersDescription(numberOfParameters)} returning .",
+ "\t");
sb.Append("\tinternal interface IReturnMethodSetupReturnBuilder : IReturnMethodSetupReturnWhenBuilder")
.AppendLine();
sb.Append("\t{").AppendLine();
-
- sb.AppendXmlSummary("Limits the return/throw to only execute for method invocations where the predicate returns true.");
- sb.AppendXmlRemarks("Provides a zero-based counter indicating how many times the method has been invoked so far.");
+
+ sb.AppendXmlSummary(
+ "Limits the return/throw to only execute for method invocations where the predicate returns true.");
+ sb.AppendXmlRemarks(
+ "Provides a zero-based counter indicating how many times the method has been invoked so far.");
sb.Append("\t\tIReturnMethodSetupReturnWhenBuilder When(Func predicate);").AppendLine();
sb.Append("\t}").AppendLine();
sb.AppendLine();
- sb.AppendXmlSummary($"Sets up a when return callback for a method with {numberOfParameters} parameters {GetTypeParametersDescription(numberOfParameters)} returning .", "\t");
+ sb.AppendXmlSummary(
+ $"Sets up a when return callback for a method with {numberOfParameters} parameters {GetTypeParametersDescription(numberOfParameters)} returning .",
+ "\t");
sb.Append("\tinternal interface IReturnMethodSetupReturnWhenBuilder : IReturnMethodSetup")
.AppendLine();
sb.Append("\t{").AppendLine();
-
+
sb.AppendXmlSummary("Repeats the callback for the given number of .");
- sb.AppendXmlRemarks($"The number of times is only counted for actual executions ( evaluates to ).");
+ sb.AppendXmlRemarks(
+ $"The number of times is only counted for actual executions ( evaluates to ).");
sb.Append("\t\tIReturnMethodSetupReturnWhenBuilder For(int times);")
.AppendLine();
sb.AppendLine();
sb.AppendXmlSummary("Deactivates the return/throw after the given number of .");
- sb.AppendXmlRemarks($"The number of times is only counted for actual executions ( evaluates to ).");
+ sb.AppendXmlRemarks(
+ $"The number of times is only counted for actual executions ( evaluates to ).");
sb.Append("\t\tIReturnMethodSetup Only(int times);").AppendLine();
sb.Append("\t}").AppendLine();
sb.AppendLine();
-
- sb.AppendXmlSummary($"Sets up a method with {numberOfParameters} parameters {GetTypeParametersDescription(numberOfParameters)} returning .", "\t");
+
+ sb.AppendXmlSummary(
+ $"Sets up a method with {numberOfParameters} parameters {GetTypeParametersDescription(numberOfParameters)} returning .",
+ "\t");
sb.Append("\tinternal class ReturnMethodSetup : MethodSetup,").AppendLine();
sb.Append("\t\tIReturnMethodSetupCallbackBuilder,").AppendLine();
@@ -795,6 +831,9 @@ private static void AppendReturnMethodSetup(StringBuilder sb, int numberOfParame
}
sb.Append(')').AppendLine();
+ sb.Append("\t\t\t: base(new MethodParameterMatch(name, [")
+ .Append(string.Join(", ", Enumerable.Range(1, numberOfParameters).Select(i => $"match{i}"))).Append("]))")
+ .AppendLine();
sb.Append("\t\t{").AppendLine();
sb.Append("\t\t\t_name = name;").AppendLine();
for (int i = 1; i <= numberOfParameters; i++)
@@ -809,6 +848,7 @@ private static void AppendReturnMethodSetup(StringBuilder sb, int numberOfParame
.Append(string.Join(", ", Enumerable.Range(1, numberOfParameters).Select(i => $"T{i}"))).Append("}\" />")
.AppendLine();
sb.Append("\t\tpublic ReturnMethodSetup(string name, IParameters matches)").AppendLine();
+ sb.Append("\t\t\t: base(new MethodParametersMatch(name, matches))").AppendLine();
sb.Append("\t\t{").AppendLine();
sb.Append("\t\t\t_name = name;").AppendLine();
sb.Append("\t\t\t_matches = matches;").AppendLine();
@@ -933,8 +973,9 @@ private static void AppendReturnMethodSetup(StringBuilder sb, int numberOfParame
sb.Append("\t\t\treturn this;").AppendLine();
sb.Append("\t\t}").AppendLine();
sb.AppendLine();
-
- sb.AppendXmlSummary("Registers a that will calculate the exception to throw when the method is invoked.");
+
+ sb.AppendXmlSummary(
+ "Registers a that will calculate the exception to throw when the method is invoked.");
sb.Append("\t\tpublic IReturnMethodSetupReturnBuilder Throws(Func<")
.Append(typeParams).Append(", Exception> callback)").AppendLine();
sb.Append("\t\t{").AppendLine();
@@ -948,7 +989,8 @@ private static void AppendReturnMethodSetup(StringBuilder sb, int numberOfParame
sb.Append("\t\t}").AppendLine();
sb.AppendLine();
- sb.AppendXmlSummary("Registers a that will calculate the exception to throw when the method is invoked.");
+ sb.AppendXmlSummary(
+ "Registers a that will calculate the exception to throw when the method is invoked.");
sb.Append("\t\tpublic IReturnMethodSetupReturnBuilder Throws(Func callback)")
.AppendLine();
@@ -1129,16 +1171,6 @@ private static void AppendReturnMethodSetup(StringBuilder sb, int numberOfParame
sb.Append("\t\t}").AppendLine();
sb.AppendLine();
- sb.Append("\t\t/// ").AppendLine();
- sb.Append("\t\tprotected override bool IsMatch(MethodInvocation invocation)").AppendLine();
- sb.Append("\t\t\t=> invocation.Name.Equals(_name) &&").AppendLine();
- sb.Append("\t\t\t\t(_matches is not null").AppendLine();
- sb.Append("\t\t\t\t\t? _matches.Matches(invocation.Parameters)").AppendLine();
- sb.Append("\t\t\t\t\t: Matches([")
- .Append(string.Join(", ", Enumerable.Range(1, numberOfParameters).Select(x => $"_match{x}!")))
- .Append("], invocation.Parameters));").AppendLine();
- sb.AppendLine();
-
sb.Append("\t\t/// ").AppendLine();
sb.Append("\t\tprotected override void TriggerParameterCallbacks(object?[] parameters)").AppendLine();
sb.Append("\t\t\t=> TriggerCallbacks([")
diff --git a/Source/Mockolate/Mock.Verify.cs b/Source/Mockolate/Mock.Verify.cs
index 4c085d9c..45182a7b 100644
--- a/Source/Mockolate/Mock.Verify.cs
+++ b/Source/Mockolate/Mock.Verify.cs
@@ -1,4 +1,5 @@
using Mockolate.Parameters;
+using Mockolate.Setup;
using Mockolate.Verify;
namespace Mockolate;
@@ -24,28 +25,28 @@ bool IMockVerify.ThatAllSetupsAreUsed()
///
VerificationResult IMockVerifyInvokedWithToString.ToString()
- => Registrations.Method(Subject, Registrations.Prefix + ".ToString");
+ => Registrations.Method(Subject, new MethodParameterMatch(Registrations.Prefix + ".ToString", []));
///
VerificationResult IMockVerifyInvokedWithEquals.Equals(IParameter