DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone >

Beginning Mocking with Moq 3 - Part 2

Justin Etheredge user avatar by
Justin Etheredge
·
Mar. 16, 09 · · News
Like (0)
Save
Tweet
6.82K Views

Join the DZone community and get the full member experience.

Join For Free

In the previous entry in this series on beginning mocking using Moq, we looked at how to create a mock and then later verify that some method was called. This is probably the most basic usage of a mocking framework, which is to simply verify a method call. One of the things that is a bit confusing when looking at a statement in a test that uses a lambda is to realize that the code you are seeing in the assertion is not actually executing. So when you see a statement like this:

mockFileWriter.Verify(fw => fw.WriteLine("1001,10.53"), Times.Exactly(1));

The lambda inside of the “Verify” method:

fw => fw.WriteLine("1001,10.53")

Is being turned into an expression tree and then analyzed by Moq, not actually being executed. Whether or not you understand what I mean by that, what you need to understand is that we are merely telling Moq what to look for, not running any code.

Read the rest of this post at CodeThinked.com

Framework POST (HTTP) Testing Tree (data structure) Assertion (software development)

Published at DZone with permission of Justin Etheredge. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Implementing RBAC Configuration for Kubernetes Applications
  • Ultra-Fast Microservices: When Microstream Meets Payara
  • A Developer Evangelist's Thoughts on Angular 2
  • Comprehensive Guide to Jenkins Declarative Pipeline [With Examples]

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo