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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T18:02:35+00:00 2026-06-02T18:02:35+00:00

I am storing data into a database by calling a function, StoreData . In

  • 0

I am storing data into a database by calling a function, StoreData. In the designer code, a SqlConnection is open, SqlCommands are run, and the SqlConnection closes. After StoreData is run succesfully, data is stored in the DB.

I would like to run an integration test to StoreData by asserting that a value that I chose for the integration test (before StoreData runs, ie. id = 0, time = "13:00") is equal to the value found in the DB (after StoreData runs, ie. id column = 0 and time_stamp column = "13:00").

I thought about using LINQ. Is this a good approach, or is there a better approach to doing this?

  • 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-06-02T18:02:36+00:00Added an answer on June 2, 2026 at 6:02 pm

    Technically, this is an integration test, and it’s perfectly valid to make a test that will read the data back out of the database and ensure it looks correct.

    However, if you want to make it a unit test, what you should do is mock the backing mechanism to be some kind of in memory structure, and then your StoreData method would insert into this structure instead of calling the database. Typically then, that would mean making some kind of factory mechanism for SqlConnection and SqlCommand and then overloading methods to make sure the query gets targeted to your in memory structure.

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

Sidebar

Related Questions

I have created one application, where I am storing the data into database and
I am trying to insert Data into my Sql-Server database though C#. I'm Calling
In my c# application i am inserting data into sqlite database as below String
Possible Duplicate: HTML5 local storage sort I am storing data into a localstorage using
I am storing my data into arraylist of one class and sending that arraylist
I am looking for some examples on storing some data into Google cloud storage
I'm storing JSON formatted data into a var adds with the following methods: var
I am storing xml data in a string into user preferences. I want to
We have a web app, which is written in Java, and storing data into
I've got a problem where I'm inserting data into a database. It's returning that

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.