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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:02:02+00:00 2026-05-26T14:02:02+00:00

In our environment, we are using a custom data access to access our legacy

  • 0

In our environment, we are using a custom data access to access our legacy Oracle database. It allows us to make calls to stored procedures and get the results back as a DataTable or as a list of name/value pairs if the data returned is only one row of data. It requires us on each call to instantiate a new object from this library and then make sure it gets disposed of upon completion.

For example, we might do something like this:

    DataReader reader = new DataReader("StoredProcedureName");
    reader.AddParameter(name, DbType.Array, ParameterDirection.Input, data);
    DataTable dt;
    try
    {
        dt = reader.Open();
    }
    finally
    {
        reader.Dispose();
    }

My problem is I am unsure of how to test methods that make database calls using this library. I am relatively new to unit testing and am trying to start using it diligently. I have gotten started using moq and have written a bunch of test cases for my other application code. I don’t know how I can mock the database library. Would it make sense to build a factory object that will create new instances of the datareader and then mock the factory?

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-26T14:02:02+00:00Added an answer on May 26, 2026 at 2:02 pm

    Your not going to be able to “unit” test the very lowest level of your code (i.e. thin wrapper around ADO.Net that you are calling your Data Access Layer). Every other layer you can use mocking to isolate it, but in order to test the very lowest layer you should just write “system” tests that will actualy hit a real database (this will involve setting it up so you can recreate the DB in a known state as part of the test run – Database Projects are great for this).

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

Sidebar

Related Questions

We are using ADAM to simulate an AD server in our development environment. We
We are using base clear case with dynamic views on Linux. In our environment
First, basic info on our environment: We're using c# .net 4.0, on Win7-x64, targeting
We are planning on introducing simple Audit Trail in our database using triggers and
I am doing projects using sockets,actually it runs in our environment without fail (LAN).
Our production environment is using an adaptation technology that is incompatible with multiple css
I am a designer using Expression Blend 4 and our environment is .NET 3.5.
Our environment: Drupal+MySQL Examining the query log indicates that the following query, originating from
In our environment we have a Lib folder which contains various third party assemblies
NHibernate is not really a good fit for our environment due to all the

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.