File tree 1 file changed +17
-0
lines changed
1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change 2
2
// All rights reserved. Licensed under the BSD 3-Clause License; see License.txt.
3
3
4
4
using System ;
5
+ using System . Linq . Expressions ;
5
6
using System . Threading . Tasks ;
6
7
7
8
using Moq ;
@@ -65,6 +66,22 @@ public void ThrowsWithExpressionIfVerifiableExpectationWithLambdaMatcherNotCalle
65
66
Assert . Contains ( @".Execute(It.Is<string>(s => string.IsNullOrEmpty(s)))" , mex . Message ) ;
66
67
}
67
68
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
+
68
85
[ Fact ]
69
86
public void VerifiesNoOpIfNoVerifiableExpectations ( )
70
87
{
You can’t perform that action at this time.
0 commit comments