Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 187521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T15:50:18+00:00 2026-05-11T15:50:18+00:00

Edit: Language/Platform is C# / .Net I’m currently trying to fill a vast unit-test

  • 0

Edit: Language/Platform is C# / .Net

I’m currently trying to fill a vast unit-test void in my current project, and being admittedly new to TDD, find myself quite stumped as to how to go about testing some of the more business-critical features.

I picked up Moq and had an easy enough time doing simple mocks, however at the core of my application lies a rather large, scary COM interop layer, which I’m having a difficult time conceptualizing how to Unit Test appropriately. The COM component is entirely 3rd party, and thus cannot be modified, and implements what amounts to a finite state machine for handling phone calls. The component notifies my application through a set of non-virtual events which I would like to test in certain orders to simulate state changes, however Moq does not offer a way to do this for anything but virtual events.

So my question to the more knowledgeable TDDers/Mockists is: How would you go about testing this sort of thing?

Apparently TypeMock supports this (in exchange for it’s own shortcomings), but I’d rather not use it for a variety of reasons regarding type-safety and my general feeling that it’s doing something devious behind my back.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T15:50:18+00:00Added an answer on May 11, 2026 at 3:50 pm

    You can only mock virtual/abstract methods, unless you use something heavy-duty like TypeMock.

    When you have to test code that you don’t have control over, you’re going to have to break your dependency on that code. Create a facade that has the methods, properties and events of the untestable class. Stick with the ones that you actually use; it’ll keep down on the size of the code you have to write. Code against the facade you control rather than the code you don’t.

    The last thing is to use one of the several techniques to access the the facade that will allow you to substitute a mock during tests. You can use config files, dependency injection frameworks, lazy instantiation, etc. This way you can mock out your facade and use it for unit tests. Of course, you’ll still have to do some integration tests to make sure your facade works correctly with the actual COM interop class.

    For some inspiration, take a look at System.Web.Abstractions. It contains many classes which wrap ASP.NET core classes to make them mockable.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 121k
  • Answers 121k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer It is not appropriate to use connection pooling if the… May 12, 2026 at 12:20 am
  • Editorial Team
    Editorial Team added an answer I set up a web application using the same configuration… May 12, 2026 at 12:20 am
  • Editorial Team
    Editorial Team added an answer I finally figured it out. It was the smallest typo… May 12, 2026 at 12:20 am

Related Questions

Edit: Language/Platform is C# / .Net I'm currently trying to fill a vast unit-test
Nikhil Kothari's Script# is quite possibly one of the most amazing concepts I've seen
This is with reference to this question: How to read output and give input
How much less libraries are there for Mono than for Java? I lack the
It seems that Apple has so far gone the furthest of any mobile platform

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.