Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Source/Mockolate/Match.AnyParameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public bool Matches(object?[] values)
=> true;

/// <inheritdoc cref="object.ToString()" />
public override string ToString() => "AnyParameters()";
public override string ToString() => "Match.AnyParameters()";
}
}
#pragma warning restore S3453 // This class can't be instantiated; make its constructor 'public'.
2 changes: 1 addition & 1 deletion Source/Mockolate/Match.Parameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public bool Matches(object?[] values)
=> predicate(values);

/// <inheritdoc cref="object.ToString()" />
public override string ToString() => $"Parameters({predicateExpression})";
public override string ToString() => $"Match.Parameters({predicateExpression})";
}
}
#pragma warning restore S3453 // This class can't be instantiated; make its constructor 'public'.
2 changes: 1 addition & 1 deletion Source/Mockolate/Match.WithDefaultParameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public static IDefaultEventParameters WithDefaultParameters()
private sealed class DefaultEventParameters : IDefaultEventParameters
{
/// <inheritdoc cref="object.ToString()" />
public override string ToString() => "WithDefaultParameters()";
public override string ToString() => "Match.WithDefaultParameters()";
}
}
#pragma warning restore S3453 // This class can't be instantiated; make its constructor 'public'.
2 changes: 1 addition & 1 deletion Tests/Mockolate.Tests/MatchTests.AnyParametersTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public async Task ShouldAlwaysMatch(params object?[] values)
public async Task ToString_ShouldReturnExpectedValue()
{
IParameters sut = Match.AnyParameters();
string expectedValue = "AnyParameters()";
string expectedValue = "Match.AnyParameters()";

string? result = sut.ToString();

Expand Down
2 changes: 1 addition & 1 deletion Tests/Mockolate.Tests/MatchTests.ParametersTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public async Task ShouldMatchWhenPredicateReturnsTrue(bool expectedResult, param
public async Task ToString_ShouldReturnExpectedValue()
{
IParameters sut = Match.Parameters(_ => true);
string expectedValue = "Parameters(_ => true)";
string expectedValue = "Match.Parameters(_ => true)";

string? result = sut.ToString();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public sealed class WithDefaultParametersTests
public async Task ToString_ShouldReturnExpectedValue()
{
IDefaultEventParameters sut = Match.WithDefaultParameters();
string expectedValue = "WithDefaultParameters()";
string expectedValue = "Match.WithDefaultParameters()";

string? result = sut.ToString();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,16 +224,6 @@ public T SetRefParameter<T>(string parameterName, T value)
public T GetReturnValue<T>(MethodInvocation invocation)
=> base.GetReturnValue<T>(invocation, MockBehavior.Default, () => default!);
}

private class MyReturnMethodSetupAnyParameterCombination<T>(string name)
: ReturnMethodSetup<Task, string>(name, Match.AnyParameters())
{
public TValue HiddenSetOutParameter<TValue>(string parameterName, Func<TValue> defaultValueGenerator)
=> SetOutParameter<TValue>(parameterName, defaultValueGenerator);

public TValue HiddenSetRefParameter<TValue>(string parameterName, TValue value, MockBehavior behavior)
=> SetRefParameter(parameterName, value, behavior);
}
}

public class ReturnMethodWith2Parameters
Expand Down Expand Up @@ -432,16 +422,6 @@ public T SetRefParameter<T>(string parameterName, T value)
public T GetReturnValue<T>(MethodInvocation invocation)
=> base.GetReturnValue<T>(invocation, MockBehavior.Default, () => default!);
}

private class MyReturnMethodSetupAnyParameterCombination<T>(string name)
: ReturnMethodSetup<Task, string, long>(name, Match.AnyParameters())
{
public TValue HiddenSetOutParameter<TValue>(string parameterName, Func<TValue> defaultValueGenerator)
=> SetOutParameter<TValue>(parameterName, defaultValueGenerator);

public TValue HiddenSetRefParameter<TValue>(string parameterName, TValue value, MockBehavior behavior)
=> SetRefParameter(parameterName, value, behavior);
}
}

public class ReturnMethodWith3Parameters
Expand Down Expand Up @@ -678,16 +658,6 @@ public T SetRefParameter<T>(string parameterName, T value)
public T GetReturnValue<T>(MethodInvocation invocation)
=> base.GetReturnValue<T>(invocation, MockBehavior.Default, () => default!);
}

private class MyReturnMethodSetupAnyParameterCombination<T>(string name)
: ReturnMethodSetup<Task, string, long, int>(name, Match.AnyParameters())
{
public TValue HiddenSetOutParameter<TValue>(string parameterName, Func<TValue> defaultValueGenerator)
=> SetOutParameter<TValue>(parameterName, defaultValueGenerator);

public TValue HiddenSetRefParameter<TValue>(string parameterName, TValue value, MockBehavior behavior)
=> SetRefParameter(parameterName, value, behavior);
}
}

public class ReturnMethodWith4Parameters
Expand Down Expand Up @@ -962,16 +932,6 @@ public T SetRefParameter<T>(string parameterName, T value)
public T GetReturnValue<T>(MethodInvocation invocation)
=> base.GetReturnValue<T>(invocation, MockBehavior.Default, () => default!);
}

private class MyReturnMethodSetupAnyParameterCombination<T>(string name)
: ReturnMethodSetup<Task, string, long, int, int>(name, Match.AnyParameters())
{
public TValue HiddenSetOutParameter<TValue>(string parameterName, Func<TValue> defaultValueGenerator)
=> SetOutParameter<TValue>(parameterName, defaultValueGenerator);

public TValue HiddenSetRefParameter<TValue>(string parameterName, TValue value, MockBehavior behavior)
=> SetRefParameter(parameterName, value, behavior);
}
}

public class ReturnMethodWith5Parameters
Expand Down Expand Up @@ -1285,16 +1245,6 @@ public T SetRefParameter<T>(string parameterName, T value)
public T GetReturnValue<T>(MethodInvocation invocation)
=> base.GetReturnValue<T>(invocation, MockBehavior.Default, () => default!);
}

private class MyReturnMethodSetupAnyParameterCombination<T>(string name)
: ReturnMethodSetup<Task, string, long, int, int, int>(name, Match.AnyParameters())
{
public TValue HiddenSetOutParameter<TValue>(string parameterName, Func<TValue> defaultValueGenerator)
=> SetOutParameter<TValue>(parameterName, defaultValueGenerator);

public TValue HiddenSetRefParameter<TValue>(string parameterName, TValue value, MockBehavior behavior)
=> SetRefParameter(parameterName, value, behavior);
}
}

public class VoidMethodWith0Parameters
Expand Down
52 changes: 36 additions & 16 deletions Tests/Mockolate.Tests/MockMethods/SetupMethodTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,16 @@ public async Task WhenSetupWithNull_ShouldReturnDefaultValue()

public class ReturnMethodWith1Parameters
{
[Fact]
public async Task ToString_AnyParameters_ShouldReturnMethodSignature()
{
ReturnMethodSetup<int, string> setup = new("Foo", Match.AnyParameters());

string result = setup.ToString();

await That(result).IsEqualTo("int Foo(Match.AnyParameters())");
}

[Fact]
public async Task ToString_ShouldReturnMethodSignature()
{
Expand Down Expand Up @@ -616,13 +626,13 @@ public async Task WhenSetupWithNull_ShouldReturnDefaultValue()
public class ReturnMethodWith2Parameters
{
[Fact]
public async Task ToString_AnyParameterCombination_ShouldReturnMethodSignature()
public async Task ToString_AnyParameters_ShouldReturnMethodSignature()
{
ReturnMethodSetup<int, string, long> setup = new("Foo", Match.AnyParameters());

string result = setup.ToString();

await That(result).IsEqualTo("int Foo(AnyParameters())");
await That(result).IsEqualTo("int Foo(Match.AnyParameters())");
}

[Fact]
Expand Down Expand Up @@ -657,13 +667,13 @@ public async Task WhenSetupWithNull_ShouldReturnDefaultValue()
public class ReturnMethodWith3Parameters
{
[Fact]
public async Task ToString_AnyParameterCombination_ShouldReturnMethodSignature()
public async Task ToString_AnyParameters_ShouldReturnMethodSignature()
{
ReturnMethodSetup<int, string, long, int> setup = new("Foo", Match.AnyParameters());

string result = setup.ToString();

await That(result).IsEqualTo("int Foo(AnyParameters())");
await That(result).IsEqualTo("int Foo(Match.AnyParameters())");
}

[Fact]
Expand Down Expand Up @@ -699,13 +709,13 @@ public async Task WhenSetupWithNull_ShouldReturnDefaultValue()
public class ReturnMethodWith4Parameters
{
[Fact]
public async Task ToString_AnyParameterCombination_ShouldReturnMethodSignature()
public async Task ToString_AnyParameters_ShouldReturnMethodSignature()
{
ReturnMethodSetup<int, string, long, int, int> setup = new("Foo", Match.AnyParameters());

string result = setup.ToString();

await That(result).IsEqualTo("int Foo(AnyParameters())");
await That(result).IsEqualTo("int Foo(Match.AnyParameters())");
}

[Fact]
Expand Down Expand Up @@ -744,13 +754,13 @@ public async Task WhenSetupWithNull_ShouldReturnDefaultValue()
public class ReturnMethodWith5Parameters
{
[Fact]
public async Task ToString_AnyParameterCombination_ShouldReturnMethodSignature()
public async Task ToString_AnyParameters_ShouldReturnMethodSignature()
{
ReturnMethodSetup<int, string, long, int, int, int> setup = new("Foo", Match.AnyParameters());

string result = setup.ToString();

await That(result).IsEqualTo("int Foo(AnyParameters())");
await That(result).IsEqualTo("int Foo(Match.AnyParameters())");
}

[Fact]
Expand Down Expand Up @@ -803,6 +813,16 @@ public async Task ToString_ShouldReturnMethodSignature()

public class VoidMethodWith1Parameters
{
[Fact]
public async Task ToString_AnyParameters_ShouldReturnMethodSignature()
{
VoidMethodSetup<string> setup = new("Foo", Match.AnyParameters());

string result = setup.ToString();

await That(result).IsEqualTo("void Foo(Match.AnyParameters())");
}

[Fact]
public async Task ToString_ShouldReturnMethodSignature()
{
Expand All @@ -818,13 +838,13 @@ public async Task ToString_ShouldReturnMethodSignature()
public class VoidMethodWith2Parameters
{
[Fact]
public async Task ToString_AnyParameterCombination_ShouldReturnMethodSignature()
public async Task ToString_AnyParameters_ShouldReturnMethodSignature()
{
VoidMethodSetup<string, long> setup = new("Foo", Match.AnyParameters());

string result = setup.ToString();

await That(result).IsEqualTo("void Foo(AnyParameters())");
await That(result).IsEqualTo("void Foo(Match.AnyParameters())");
}

[Fact]
Expand All @@ -843,13 +863,13 @@ public async Task ToString_ShouldReturnMethodSignature()
public class VoidMethodWith3Parameters
{
[Fact]
public async Task ToString_AnyParameterCombination_ShouldReturnMethodSignature()
public async Task ToString_AnyParameters_ShouldReturnMethodSignature()
{
VoidMethodSetup<string, long, int> setup = new("Foo", Match.AnyParameters());

string result = setup.ToString();

await That(result).IsEqualTo("void Foo(AnyParameters())");
await That(result).IsEqualTo("void Foo(Match.AnyParameters())");
}

[Fact]
Expand All @@ -869,13 +889,13 @@ public async Task ToString_ShouldReturnMethodSignature()
public class VoidMethodWith4Parameters
{
[Fact]
public async Task ToString_AnyParameterCombination_ShouldReturnMethodSignature()
public async Task ToString_AnyParameters_ShouldReturnMethodSignature()
{
VoidMethodSetup<string, long, int, int> setup = new("Foo", Match.AnyParameters());

string result = setup.ToString();

await That(result).IsEqualTo("void Foo(AnyParameters())");
await That(result).IsEqualTo("void Foo(Match.AnyParameters())");
}

[Fact]
Expand All @@ -898,13 +918,13 @@ await That(result)
public class VoidMethodWith5Parameters
{
[Fact]
public async Task ToString_AnyParameterCombination_ShouldReturnMethodSignature()
public async Task ToString_AnyParameters_ShouldReturnMethodSignature()
{
VoidMethodSetup<string, long, int, int, int> setup = new("Foo", Match.AnyParameters());

string result = setup.ToString();

await That(result).IsEqualTo("void Foo(AnyParameters())");
await That(result).IsEqualTo("void Foo(Match.AnyParameters())");
}

[Fact]
Expand Down
Loading