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 7032281
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:54:51+00:00 2026-05-28T00:54:51+00:00

I am new to unit testing/TDD and having problem getting my head certain aspects

  • 0

I am new to unit testing/TDD and having problem getting my head certain aspects of it. For example I am not sure how complete the tests should be imagine the following scenario.

I am writing a test to ensure I get the correct prices for a product. A product can come in different sizes and bought in a number of defined quantities. The price of the product will reflect the size and quantity.

For example:

Product A has the pricing matrix below (quantity down the side and size along the top)

----------------------------
|     | xs |  s |  m |  l  | 
----------------------------
|  250| 10 | 20 | 50 | 100 | 
----------------------------
|  500| 20 | 40 | 60 | 110 | 
----------------------------
| 1000| 15 | 25 | 55 | 105 | 
----------------------------
| 1500| 12 | 22 | 52 | 102 | 
----------------------------

Now say I was writing tests for a class method

Pricer.GetPrice(Product p, string size, int quantity)

Should I test for every product/size/quantity combo? as you can imagine this could mean a large number of tests.

If the prices are sourced from a data store and thus liable to change how do you keep your tests correct or is that just a annoying by product?

Also does anyone have any good links to read regarding writing tests/TDD. Maybe going through CRUD/Repositories as this seems a bit of a chicken and egg type scenario.

  • 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-28T00:54:52+00:00Added an answer on May 28, 2026 at 12:54 am

    It sounds like there are two elements to your pricing logic.

    1. A price matrix data structure mapping (size, quantity cutoff) pairs to prices.

    2. A function that takes a price matrix and a Product instance and returns a price.

    Testing the price matrix is meaningless; the numbers are arbitrary. If you feel you need to test the function, I would pass it different fake, hard-coded test matrices with different mock products and test to verify that the right price comes out. The most relevant edge cases are probably when you ask for a price for a cutoff quantity exactly or off-by-one from one.

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

Sidebar

Related Questions

I'm new to Unit Testing, and I'm only getting into the routine of building
I am 'relatively new' to unit-testing and TDD. Only more recently have I completed
I have started practicing TDD approach. I am pretty much new to unit testing.
I'm not brand new to the concept of unit testing but at the same
I'm pretty new to TDD and unit testing and I'm giving it a try
I'm very new to TDD and I'm having trouble with one of my unit
I'm unit testing with easymock and having a result not set in the answer
I have not been doing TDD and Unit Tests for 7 months now and
I'm new to unit testing. But how do I unit test my DAL which
I'm new to unit testing and nUnit (2.48). I'd like to write a test

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.