Click here to Skip to main content
15,912,977 members
Home / Discussions / C#
   

C#

 
QuestionApplication.Exit();, Environment.Exit(0); or this.Close(); Pin
Vandretta23-May-08 23:23
Vandretta23-May-08 23:23 
AnswerRe: Application.Exit();, Environment.Exit(0); or this.Close(); Pin
Giorgi Dalakishvili24-May-08 1:02
mentorGiorgi Dalakishvili24-May-08 1:02 
AnswerRe: Application.Exit();, Environment.Exit(0); or this.Close(); Pin
PIEBALDconsult24-May-08 3:35
mvePIEBALDconsult24-May-08 3:35 
GeneralRe: Application.Exit();, Environment.Exit(0); or this.Close(); Pin
Vandretta24-May-08 16:05
Vandretta24-May-08 16:05 
QuestionMocking objects Pin
N a v a n e e t h23-May-08 21:53
N a v a n e e t h23-May-08 21:53 
AnswerRe: Mocking objects Pin
Colin Angus Mackay23-May-08 23:22
Colin Angus Mackay23-May-08 23:22 
GeneralRe: Mocking objects Pin
N a v a n e e t h24-May-08 7:22
N a v a n e e t h24-May-08 7:22 
GeneralRe: Mocking objects Pin
Colin Angus Mackay24-May-08 8:49
Colin Angus Mackay24-May-08 8:49 
N a v a n e e t h wrote:
I need to ensure that, my code is inserting values to a table and it's related values to other table. So how do I use mock objects here ? Just a clue will help me to get started.


Okay - If the application is properly layered your business code will know nothing about the database. Therefore when you are testing your business code you mock the DAL classes (which are acting as the buffer between your application and the database). There will be no database interaction going on, and no need to mock the database itself because your mock objects will be returning the values to the business layer.

If you are testing the DAL layer itself then you may want to mock the database out. However, the way I usually create the DAL layer is that it acts as a proxy to the stored procedures in the database. In this case I don't mock anything out because what I'm really doing is testing the database and the easiest way to do that is through the DAL.

If your DAL is more complex then you may want to mock out the database calls.

However, from what you are saying "I need to ensure that my code is inserting values to a table and it's related values to other table" then what you doing is testing the database itself. Remember you cannot mock the thing you are testing because if you do the test will be flawed as the test will only be testing the mock object.

So, if you are testing the database, its stored procedures and triggers then you are going to have to have your tests create test data in the database for the tests to use. These are more time consuming tests as you will have to reset the database between tests so that it is in a consistent state. I've found that restoring known backups (small backups) to be fairly efficient without getting bogged down in too much T-SQL.

I hope that helps.


GeneralRe: Mocking objects Pin
N a v a n e e t h24-May-08 9:02
N a v a n e e t h24-May-08 9:02 
GeneralRe: Mocking objects Pin
Colin Angus Mackay24-May-08 9:31
Colin Angus Mackay24-May-08 9:31 
GeneralRe: Mocking objects Pin
N a v a n e e t h24-May-08 18:13
N a v a n e e t h24-May-08 18:13 
GeneralRe: Mocking objects Pin
Colin Angus Mackay24-May-08 22:57
Colin Angus Mackay24-May-08 22:57 
GeneralRe: Mocking objects Pin
N a v a n e e t h25-May-08 7:03
N a v a n e e t h25-May-08 7:03 
GeneralRe: Mocking objects Pin
N a v a n e e t h25-May-08 18:48
N a v a n e e t h25-May-08 18:48 
QuestionFormatting a number Pin
N.Surendra Prasad23-May-08 20:43
N.Surendra Prasad23-May-08 20:43 
GeneralRe: Formatting a number Pin
Krazy Programmer23-May-08 20:45
Krazy Programmer23-May-08 20:45 
AnswerRe: Formatting a number Pin
DaveyM6923-May-08 22:19
professionalDaveyM6923-May-08 22:19 
GeneralRe: Formatting a number Pin
N.Surendra Prasad25-May-08 17:29
N.Surendra Prasad25-May-08 17:29 
GeneralRe: Formatting a number Pin
DaveyM6925-May-08 22:26
professionalDaveyM6925-May-08 22:26 
GeneralRe: Formatting a number Pin
DaveyM6925-May-08 23:02
professionalDaveyM6925-May-08 23:02 
QuestionC# noob needs help with udp & in general Pin
DrWigglechin23-May-08 19:29
DrWigglechin23-May-08 19:29 
AnswerRe: C# noob needs help with udp & in general Pin
leppie24-May-08 8:39
leppie24-May-08 8:39 
QuestionHow to update exe file after install application Pin
cocoonwls23-May-08 16:32
cocoonwls23-May-08 16:32 
AnswerRe: How to update exe file after install application Pin
Ravi Bhavnani23-May-08 16:59
professionalRavi Bhavnani23-May-08 16:59 
GeneralRe: How to update exe file after install application Pin
cocoonwls23-May-08 18:15
cocoonwls23-May-08 18:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.