File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22// All rights reserved. Licensed under the BSD 3-Clause License; see License.txt.
33
44using System ;
5+ using System . Linq . Expressions ;
56using System . Threading . Tasks ;
67
78using Moq ;
@@ -65,6 +66,22 @@ public void ThrowsWithExpressionIfVerifiableExpectationWithLambdaMatcherNotCalle
6566 Assert . Contains ( @".Execute(It.Is<string>(s => string.IsNullOrEmpty(s)))" , mex . Message ) ;
6667 }
6768
69+ [ Fact ]
70+ public void ThrowsWithExpressionIfVerifiableExpectationWithLambdaMatcherVariableNotCalled ( )
71+ {
72+ var mock = new Mock < IFoo > ( ) ;
73+
74+ Expression < Func < string , bool > > nullOrEmpty = s => string . IsNullOrEmpty ( s ) ;
75+
76+ mock . Setup ( x => x . Execute ( It . Is ( nullOrEmpty ) ) )
77+ . Returns ( "ack" )
78+ . Verifiable ( ) ;
79+
80+ var mex = Assert . Throws < MockException > ( ( ) => mock . Verify ( ) ) ;
81+ Assert . True ( mex . IsVerificationError ) ;
82+ Assert . Contains ( @".Execute(It.Is<string>(s => string.IsNullOrEmpty(s)))" , mex . Message ) ;
83+ }
84+
6885 [ Fact ]
6986 public void VerifiesNoOpIfNoVerifiableExpectations ( )
7087 {
You can’t perform that action at this time.
0 commit comments