Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
20 changes: 0 additions & 20 deletions Source/Mockolate/Setup/ReturnMethodSetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -420,11 +420,6 @@ protected override TResult GetReturnValue<TResult>(MethodInvocation invocation,
Func<TResult> defaultValueGenerator)
where TResult : default
{
if (_returnCallbacks.Count == 0)
{
return defaultValueGenerator();
}

if (!TryCast(invocation.Parameters[0].Value, out T1 p1, behavior))
{
throw new MockException(
Expand Down Expand Up @@ -709,11 +704,6 @@ protected override TResult GetReturnValue<TResult>(MethodInvocation invocation,
Func<TResult> defaultValueGenerator)
where TResult : default
{
if (_returnCallbacks.Count == 0)
{
return defaultValueGenerator();
}

if (!TryCast(invocation.Parameters[0].Value, out T1 p1, behavior))
{
throw new MockException(
Expand Down Expand Up @@ -1013,11 +1003,6 @@ protected override TResult GetReturnValue<TResult>(MethodInvocation invocation,
Func<TResult> defaultValueGenerator)
where TResult : default
{
if (_returnCallbacks.Count == 0)
{
return defaultValueGenerator();
}

if (!TryCast(invocation.Parameters[0].Value, out T1 p1, behavior))
{
throw new MockException(
Expand Down Expand Up @@ -1335,11 +1320,6 @@ protected override TResult GetReturnValue<TResult>(MethodInvocation invocation,
Func<TResult> defaultValueGenerator)
where TResult : default
{
if (_returnCallbacks.Count == 0)
{
return defaultValueGenerator();
}

if (!TryCast(invocation.Parameters[0].Value, out T1 p1, behavior))
{
throw new MockException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,18 @@ public async Task SetupWithoutReturn_ShouldUseBaseValue()
await That(result).IsEqualTo("foo");
}

[Fact]
public async Task SetupWithReturn_ShouldUseBaseValue()
Comment thread
vbreuss marked this conversation as resolved.
Outdated
{
ReturnMethodSetupTest sut = Mock.Create<ReturnMethodSetupTest>();
sut.SetupMock.Method.Method0()
.Returns("bar");

string result = sut.Method0();

await That(result).IsEqualTo("bar");
}

[Fact]
public async Task Throws_Callback_ShouldThrowException()
{
Expand Down Expand Up @@ -491,6 +503,18 @@ public async Task SetupWithoutReturn_ShouldUseBaseValue()
await That(result).IsEqualTo("foo-1");
}

[Fact]
public async Task SetupWithReturn_ShouldUseBaseValue()
Comment thread
vbreuss marked this conversation as resolved.
Outdated
{
ReturnMethodSetupTest sut = Mock.Create<ReturnMethodSetupTest>();
sut.SetupMock.Method.Method1(It.IsAny<int>())
.Returns("bar");

string result = sut.Method1(1);

await That(result).IsEqualTo("bar");
}

[Fact]
public async Task Throws_Callback_ShouldThrowException()
{
Expand Down Expand Up @@ -818,6 +842,18 @@ public async Task SetupWithoutReturn_ShouldUseBaseValue()
await That(result).IsEqualTo("foo-1-2");
}

[Fact]
public async Task SetupWithReturn_ShouldUseBaseValue()
Comment thread
vbreuss marked this conversation as resolved.
Outdated
{
ReturnMethodSetupTest sut = Mock.Create<ReturnMethodSetupTest>();
sut.SetupMock.Method.Method2(It.IsAny<int>(), It.IsAny<int>())
.Returns("bar");

string result = sut.Method2(1, 2);

await That(result).IsEqualTo("bar");
}

[Fact]
public async Task Throws_Callback_ShouldThrowException()
{
Expand Down Expand Up @@ -1151,6 +1187,18 @@ public async Task SetupWithoutReturn_ShouldUseBaseValue()
await That(result).IsEqualTo("foo-1-2-3");
}

[Fact]
public async Task SetupWithReturn_ShouldUseBaseValue()
Comment thread
vbreuss marked this conversation as resolved.
Outdated
{
ReturnMethodSetupTest sut = Mock.Create<ReturnMethodSetupTest>();
sut.SetupMock.Method.Method3(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>())
.Returns("bar");

string result = sut.Method3(1, 2, 3);

await That(result).IsEqualTo("bar");
}

[Fact]
public async Task Throws_Callback_ShouldThrowException()
{
Expand Down Expand Up @@ -1486,6 +1534,18 @@ public async Task SetupWithoutReturn_ShouldUseBaseValue()
await That(result).IsEqualTo("foo-1-2-3-4");
}

[Fact]
public async Task SetupWithReturn_ShouldIgnoreBaseValue()
{
ReturnMethodSetupTest sut = Mock.Create<ReturnMethodSetupTest>();
sut.SetupMock.Method.Method4(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>())
.Returns("bar");

string result = sut.Method4(1, 2, 3, 4);

await That(result).IsEqualTo("bar");
}

[Fact]
public async Task Throws_Callback_ShouldThrowException()
{
Expand Down Expand Up @@ -1833,6 +1893,19 @@ public async Task SetupWithoutReturn_ShouldUseBaseValue()
await That(result).IsEqualTo("foo-1-2-3-4-5");
}

[Fact]
public async Task SetupWithReturn_ShouldIgnoreBaseValue()
{
ReturnMethodSetupTest sut = Mock.Create<ReturnMethodSetupTest>();
sut.SetupMock.Method.Method5(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>(),
It.IsAny<int>())
.Returns("bar");

string result = sut.Method5(1, 2, 3, 4, 5);

await That(result).IsEqualTo("bar");
}

[Fact]
public async Task Throws_Callback_ShouldThrowException()
{
Expand Down
Loading