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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:19:54+00:00 2026-05-31T21:19:54+00:00

I have a class with a method called DataIn(int InputID, string CSVValue) , this

  • 0

I have a class with a method called DataIn(int InputID, string CSVValue), this is the main entry point to it.

This method based on the InputID stores the CSV Value parameter into relevant List<string>'s. When the InputID is the same as a property called NoOfRows it then creates one List<string> made up of all the others. It then checks the validity of this final List<string>, if all is ok then it adds the results to a HashSet<int> as a quick way of checking for duplicates.

I have broken this logic into 3 methods so DataIn calls StoreData, when the InputID in DataIn = NoOfRows it calls MergeData which calls ValidateData.

My question is should I make these methods public to test them separately or should I keep them private and pass in data to DataIn and the do asserts on the merged data List<string> and the HashSet<int>. DataIn will be the method that is called from outside the class, making the other methods public would only be for unit testing.

My concern is that if I make the other methods public and test they are ok I am then not testing DataIn works as expected or if I do both I end up with duplicate tests.

What’s your advice?

  • 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-31T21:19:55+00:00Added an answer on May 31, 2026 at 9:19 pm

    Always stick to the principle of least privilege. Exposing private methods as public just to make them unit testable is not a good design. Instead, stick to testing the public interfaces only. If a method behaves in multiple ways with different inputs, make sure that you write a test per behavior expected and you should a neat and clean design, while still being well tested.

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

Sidebar

Related Questions

Suppose that we have a class called class1. The class1 has a method called
I have a class that requires a specific method to be called before being
I have a controller which has a method called history class UsersController < ApplicationController
So I have a very simple class that has a method called getThumbUrl() but
I have created a class library called AddServiceLibrary in which I have a method
I have an object class called BOM. It has a method, getChildItem() which returns
Essentially I have a method of a class called killProgram, which is intended to
Suppose you have a private static method called Inst() which allows the class to
I have an abstract class, Foo, that has a non-abstract method called Bar. I
I have a Booking controller class (generated, NetBeans), having update method, called from JSF

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.