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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:45:14+00:00 2026-05-23T08:45:14+00:00

Sorry for the long post… While being introduced to a brown field project, I’m

  • 0

Sorry for the long post…

While being introduced to a brown field project, I’m having doubts regarding certain sets of unit tests and what to think. Say you had a repostory class, wrapping a stored procedure and in the developer guide book, a certain set guidelines (rules), describe how this class should be constructured. The class could look like the following:

public class PersonRepository
{
public PersonCollection FindPersonsByNameAndCity(string personName, string cityName)
{
    using (new SomeProfiler("someKey"))
    {
        var sp = Ioc.Resolve<IPersonStoredProcedure>();

        sp.addNameArguement(personName);
        sp.addCityArguement(cityName);

        return sp.invoke();
    }
} }

Now, I would of course write some integration tests, testing that the SP can be invoked, and that the behavior is as expected. However, would I write unit tests that assert that:

  • Constructor for SomeProfiler with the input parameter “someKey” is called
  • The Constructor of PersonStoredProcedure is called
  • The addNameArgument method on the stored procedure is called with parameter personName
  • The addCityArgument method on the stored procedure is called with parameter cityName
  • The invoke method is called on the stored procedure –

If so, I would potentially be testing the whole structure of a method, besides the behavior. My initial thought is that it is overkill. However, in regards to the coding practices enforced by the team, these test ensure a uniform and ‘correct’ structure and that the next layer is called correctly (from DAL to DB, BLL to DAL etc).

In my case these type of tests, are performed for each layer of the application.

Follow up question – the use of the SomeProfiler class smells a little like a convention to me – Instead creating explicit tests for this, could one create convention styled test by using static code analysis or unittest + reflection?

Thanks in advance.

  • 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-23T08:45:15+00:00Added an answer on May 23, 2026 at 8:45 am

    I think that your initial thought was right – this is an overkill. Although you can use reflection to make sure that the class has the methods you expect I’m not sure you want to test it that way.

    Perhaps instead of unit testing you should use some tool such as FxCop/StyleCop or nDepend to make sure all of the classes in a specific assembly/dll has these properties.

    Having said that I’m a believer of “only code what you need” why test that a method exist, either you use it somewhere in your code and in that can you can test the specific case or you don’t – and so it’s irrelevant.

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

Sidebar

Related Questions

(Sorry for long post) Ok guys, so I'm having some issues with something I'm
Sorry for the long post...I'm have a habit of being pretty verbose. :-P I
Sorry for long winded post. I am trying to understand UIScrollView and running into
Sorry for this long post. The question is however small but requires full detail.
Sorry for the long post, but most of it is code spelling out my
Hello (this is a long post sorry), I am writing a application in ASP.NET
Sorry if this post appears to be long winded. I have a parent repeater
First of all, sorry if I end up making a too long post, but
Sorry for the long post that follows. I know that it is not a
Sorry for the long post, but this forum always asks for use cases :-).

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.