File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed
Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -203,11 +203,16 @@ using BbQ.MockLite;
203203// Track method calls with custom logic using strongly-typed handlers
204204var auditLog = new List <string >();
205205var builder = Mock .Create <IUserRepository >()
206+ // Traditional approach with object array
206207 .OnCall (x => x .GetUser (It .IsAny <string >()),
207- (string userId ) => auditLog .Add ($" GetUser called with: {userId }" ))
208+ args => auditLog .Add ($" GetUser called with: {args [0 ]}" ))
209+ // Strongly-typed approach (new)
208210 .OnCall (x => x .SaveUser (It .IsAny <User >()),
209- args => args [0 ] is User u && u .IsAdmin ,
210- args => auditLog .Add ($" Admin user saved: {((User )args [0 ]).Name }" ));
211+ (User user ) => auditLog .Add ($" SaveUser called with: {user .Name }" ))
212+ // Conditional callback with matcher
213+ .OnCall (x => x .DeleteUser (It .IsAny <string >()),
214+ args => args [0 ] is string id && id .StartsWith (" admin" ),
215+ args => auditLog .Add ($" Admin user deleted: {args [0 ]}" ));
211216
212217var mock = builder .Object ;
213218
You can’t perform that action at this time.
0 commit comments