diff --git a/tests/Moq.Tests/VerifyFixture.cs b/tests/Moq.Tests/VerifyFixture.cs index fca403ad1..0aedf693b 100644 --- a/tests/Moq.Tests/VerifyFixture.cs +++ b/tests/Moq.Tests/VerifyFixture.cs @@ -2,6 +2,7 @@ // All rights reserved. Licensed under the BSD 3-Clause License; see License.txt. using System; +using System.Linq.Expressions; using System.Threading.Tasks; using Moq; @@ -65,6 +66,22 @@ public void ThrowsWithExpressionIfVerifiableExpectationWithLambdaMatcherNotCalle Assert.Contains(@".Execute(It.Is(s => string.IsNullOrEmpty(s)))", mex.Message); } + [Fact] + public void ThrowsWithExpressionIfVerifiableExpectationWithLambdaMatcherVariableNotCalled() + { + var mock = new Mock(); + + Expression> nullOrEmpty = s => string.IsNullOrEmpty(s); + + mock.Setup(x => x.Execute(It.Is(nullOrEmpty))) + .Returns("ack") + .Verifiable(); + + var mex = Assert.Throws(() => mock.Verify()); + Assert.True(mex.IsVerificationError); + Assert.Contains(@".Execute(It.Is(s => string.IsNullOrEmpty(s)))", mex.Message); + } + [Fact] public void VerifiesNoOpIfNoVerifiableExpectations() {