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

  • Home
  • SEARCH
  • 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 3432292
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T07:25:52+00:00 2026-05-18T07:25:52+00:00

Am trying to get started using TDD on a class which spits out an

  • 0

Am trying to get started using TDD on a class which spits out an object belonging to a third party component. However am getting a bit confused in that apparently:

a) With unit tests objects should be tested in isolation

b) Third-party components should be wrapped into an adapter

Do these rules apply when writing tests for code which returns an instance of an object belonging to a third party component? As an example, here’s the test so far:

// Arrange
string foodXml = "<food><ingredient>Cabbages</ingredient>" +
                 "<ingredient>Bananas</ingredient></food>";
IFoodMixer mixer = new FoodMixer();

// Act

// Smoothie is the third-party component object
Smoothie urgh = mixer.Mix(foodXml);

// Assert

Assert.AreEquals("Cabbages", urgh.Ingredients[0].Name);
Assert.AreEquals("Bananas", urgh.Ingredients[1].Name);

Apologies if this question seems a bit basic (or if the concept above seems a tad silly!) – am just struggling to understand how the two rules above could apply in this situation.

Thanks in advance for any advice given!

  • 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. Editorial Team
    Editorial Team
    2026-05-18T07:25:53+00:00Added an answer on May 18, 2026 at 7:25 am

    I would be practical with it. If Smoothie is just a data object, don’t bother wrapping it.

    There’s something inside that FoodMixer which is creating the Smoothie in the first place. If that’s a 3rd party component, I would wrap it up (you can delegate from a class to a static method if required), then dependency-inject the wrapper and mock it out in your unit test.

    Your unit test is then describing the behaviour and responsibilities of your FoodMixer, independently of the SmoothieMaker (whether it’s 3rd-party or otherwise). Part of the FoodMixer’s responsibility is to ask the SmoothieMaker for a Smoothie, not to actually make the Smoothie itself. By mocking it out we can express that responsibility and class scope.

    If your Smoothie is not just a data object but has rich behaviour, I would wrap that within your wrapped SmoothieMaker too.

    Now you are completely decoupled from your 3rd party libraries, and you can unit-test easily as a useful by-product.

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

Sidebar

Related Questions

I am trying to get started developing using the .NET Micro Framework but appear
I'm trying to get started using git, but I'm having some troubles right away.
I'm trying to get started using Git and TortoiseGit. Is there a way to
I'm trying to get started using Python for KDE development. What is the canonical
I'm trying to get started using agsXMPP , but I'm having some problems. I'm
I'm trying to get started with gtkmm, and I'm using a mac. So I
I'm trying to get started using the latest Entity Framework 4 release on Visual
I'm trying to get started with Twilio's REST API using the rubygem twilio-ruby ,
I'm new to JSP, using Eclipse, and am trying to just get started with
I am trying Django recently in Ububtu. So started using a developement environment, which

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.