Skip to content

Commit

Permalink
Add failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
stakx committed Dec 3, 2017
1 parent e9e153c commit 2818672
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Moq.Tests/CustomDefaultValueProviderFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,24 @@ public void Inner_mocks_inherit_custom_default_value_provider_from_outer_mock()
Assert.Equal(expectedReturnValue, actualReturnValue);
}

[Fact]
public void FluentMockContext_properly_restores_custom_default_value_provider()
{
var customDefaultValueProvider = new ConstantDefaultValueProvider(42);
var mock = new Mock<IFoo>() { DefaultValueProvider = customDefaultValueProvider };

mock.VerifySet(m => m.Inner.Value = 1, Times.Never);
// ^^^^^^^^^^^^^^^^^^^^^^
// Moq has to execute this action to analyse what is being set. Because this is a multi-dot expression,
// it temporarily switches to DefaultValue.Mock. Once it's done, it should switch back to the one we
// set up above.

Assert.Same(customDefaultValueProvider, mock.DefaultValueProvider);
}

public interface IFoo
{
int Value { get; set; }
int GetValue();
int[] GetValues();
IFoo Inner { get; }
Expand Down

0 comments on commit 2818672

Please sign in to comment.