How can I test database interactions in c# [closed] - c#

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
A bit of background: I've been mostly developing in Java and Javascript for the past years and recently i've been moved to a C# project and tasked with implementing a Data Access Layer for this project. As far as i understood it this DAL will call only stored procedures (so no simple sql queries) and return some value if the stored procedure asks for it.
I apologize if this question has been answered before but i was not able to find anything useful.
What would be the best way to test that a DAL is actually calling these stored procedures and returning the results I am expecting? In Java we used Arquillian for integration tests against the DB and it worked great, however i have not been able to find anything like that for C#.
Any help will be appreciated.

Write unit tests for your DAL using something like nunit. This can then test that the results are as expected.

Related

How to make a plug and play WPF app create a SQL database? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I'm currently learning WPF with the goal of making a simple app for a friend. This app will make use of a database and the PC were it will run won't be connected to the internet.
I know how to make a simple database using the server management studio, and how to connect to it in my code. But so far, all tutorials/docs I've seen only talk about making use of a database in my pc, but in the case when I finish said app, how I go about setting all of this up in his (or any other)?
The end goal is for the app to be 'plug and play' and that the database files can be easily backed up.
I don't expected a step by step process! Just some direction for where to look for would be more than enough... thank you.
Use an SQLite DB, can be part of the App

How to make the currency for an economy bot? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I am trying to make an economy bot for discord using C#. I am confused about how I am going to do it. I might have to use databases but in that case how do I make it so it makes a new line for every user that has used the command. Any help would be nice, thanks.
You need to use a database. If this is your first time using databases, I highly recommened SQLite. You should also see video tutorials such as this one.
Once you have familiarised yourself with a SQLite databases then you will be able to answer your own question extremely easily. It is not difficult and requires some very simple logic. Attempt it yourself first and if you are still stuck reply to this answer.
Consider viewing this W3Schools resource when you are comfortable with the basics.

UNIT TEST: How can I use Unit Test for Database? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
If whole of my codes only distribute data to database or get data from database, how can I use Unit Test for that?
While on https://codeutopia.net/blog/2015/03/01/unit-testing-tdd-and-bdd/ says :
A Unit Test should be isolated from dependencies – for example, no network access and no database access.
Stub out only the calls to DB or any other external resource. then all your code block will get covered. If there are codes which shouldn't be part of unit test then exclude them from code coverage using a Run Setting file

C# Optional params for build sql string best way [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
i'm trying to see which is the best way or practise for sql string optimizations in c#, mssql. What i'm trying to do is like a crud system where we send the necessary required params such as db name and table and after we have the conditional, for example if its a remove action, we will have an where condition and it can contain more than 1 param so what i wanna know is get the whole params.
Should i accept an array with those conditions or what i must do.
Thanks
Not exactly an answer to your question but you should consider using ORM tool like NHibernate.
With NHibernate, you can accept QueryCriteria or ICriteria from outside world which will do the query accordingly.
Be warned that this will be big change in your application and NHibernate have steep learning curve.
There are also simple micro-ORMs available like Dapper. With it, you can implement Repository pattern by creating Data Access Layer. Refer this link.

How to update Database Using Database first approach [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I have been trying to update the database when we deploy the application on the client's machine using sql queries. Now i want to update the database automatically. Is there any way to do this, i have heard of SQLMigrations but they say that it can only be used with Code first approach. Can anyone shed some light on this topic
You can use a Database Project in Visual Studio. With Database Projects, you can generate SQL Scripts for any existing database, you can create difference (update) scripts, you can add SQL scripts of your own, etc.
Database Projects are extremely handy in many scenarios. Check out this link on MSDN: http://msdn.microsoft.com/en-us/library/xee70aty.aspx
There is also guidance on CodeProject about this: http://www.codeproject.com/Articles/245612/Creating-a-Database-Project-with-Visual-Studio
You'll love it!

Categories