Click here to Skip to main content
15,921,793 members
Home / Discussions / C#
   

C#

 
GeneralRe: Regex Pin
Angelinna16-Aug-08 10:33
Angelinna16-Aug-08 10:33 
GeneralRe: Regex Pin
Mohammad Dayyan17-Aug-08 0:54
Mohammad Dayyan17-Aug-08 0:54 
GeneralRe: Regex Pin
Angelinna17-Aug-08 17:36
Angelinna17-Aug-08 17:36 
GeneralRe: Regex Pin
Mohammad Dayyan18-Aug-08 2:26
Mohammad Dayyan18-Aug-08 2:26 
QuestionHow to determine DataGridView column datatype Pin
baranils15-Aug-08 21:08
baranils15-Aug-08 21:08 
AnswerRe: How to determine DataGridView column datatype Pin
dan!sh 15-Aug-08 23:13
professional dan!sh 15-Aug-08 23:13 
GeneralRe: How to determine DataGridView column datatype Pin
baranils15-Aug-08 23:18
baranils15-Aug-08 23:18 
Questionlearning Unit Tests / nUnit (in C#, msvs2005) Pin
noway00115-Aug-08 16:59
noway00115-Aug-08 16:59 
Hi,
I need to learn how to do unit tests for certain functions. I have googled and come accross some stuff, but all the examples are easy.
I read multiple articles on code project, but it didn't help. Usually, I see examples of unit testings functions that take in 1-2 parameters and perform addition/multiplication/etc.
I need to know how to unit test functions that return nothing, take in no parameters, and so on. For example, how do I write unit tests for a function that simply executes a SQL stored procedure? Or a function that just calls other functions?
For example:

private static void DoStuff()
{
  int x = 0, y = 0, z = 0;

  Function1();
  x = Function2();
  if(x > y)
    Function3();
}


Or something like:
private static void ExecProc(int vidID)
{
  try
  {
    SqlCommand cmd  = new SqlCommand("blah", conn);
    cmd.CommandType = CommandType.StoredProcedure;
    cmd.Parameters.Add(new SqlParameter("@vidID", vidID));
    cmd.ExecuteNonQuery();
  }
  catch (Exception e)
  {
    Console.WriteLine("error: " + e.ToString());
  }
}


I know how to do unit tests for the simple examples, where functions take in a parameter or two, and give some output in certain cases. However, when there is no output, when there is no input, when they talk to the DB or execute stored procs...what are proper unit tests?

I am using Visual Studio 2005 (C#) and have access to nUnit. Ideally, I'd like to learn how to write unit tests (manually) for the above examples, and then learn to use nUnit.

Any help you can provide is appreciated. Also, any links my googling didn't turn up would be appreciated as well. I'm really lost, and am sick of finding the same example that uses functions performing simple arithmetic.
Thanks!
AnswerRe: learning Unit Tests / nUnit (in C#, msvs2005) Pin
N a v a n e e t h15-Aug-08 17:45
N a v a n e e t h15-Aug-08 17:45 
GeneralRe: learning Unit Tests / nUnit (in C#, msvs2005) Pin
noway00117-Aug-08 10:02
noway00117-Aug-08 10:02 
QuestionWeb Browser Navigation Help Pin
ekimfeenux15-Aug-08 14:10
ekimfeenux15-Aug-08 14:10 
QuestionClipboard Exception ? Pin
Mohammad Dayyan15-Aug-08 13:22
Mohammad Dayyan15-Aug-08 13:22 
AnswerRe: Clipboard Exception ? Pin
Paul Conrad15-Aug-08 13:27
professionalPaul Conrad15-Aug-08 13:27 
GeneralRe: Clipboard Exception ? Pin
Mohammad Dayyan15-Aug-08 13:31
Mohammad Dayyan15-Aug-08 13:31 
GeneralRe: Clipboard Exception ? Pin
Paul Conrad15-Aug-08 13:34
professionalPaul Conrad15-Aug-08 13:34 
AnswerRe: Clipboard Exception ? Pin
JoeRip15-Aug-08 13:42
JoeRip15-Aug-08 13:42 
GeneralRe: Clipboard Exception ? Pin
Mohammad Dayyan16-Aug-08 2:18
Mohammad Dayyan16-Aug-08 2:18 
QuestionHow thread safe are static fields? Pin
JoeRip15-Aug-08 12:47
JoeRip15-Aug-08 12:47 
AnswerRe: How thread safe are static fields? Pin
Mark Salsbery15-Aug-08 12:53
Mark Salsbery15-Aug-08 12:53 
GeneralRe: How thread safe are static fields? Pin
JoeRip15-Aug-08 12:56
JoeRip15-Aug-08 12:56 
GeneralRe: How thread safe are static fields? Pin
Mark Salsbery15-Aug-08 13:29
Mark Salsbery15-Aug-08 13:29 
GeneralRe: How thread safe are static fields? Pin
JoeRip15-Aug-08 13:47
JoeRip15-Aug-08 13:47 
QuestionDo I still need to LOCK a Synchronized Queue? Pin
JoeRip15-Aug-08 11:51
JoeRip15-Aug-08 11:51 
AnswerRe: Do I still need to LOCK a Synchronized Queue? Pin
Wendelius15-Aug-08 12:30
mentorWendelius15-Aug-08 12:30 
GeneralRe: Do I still need to LOCK a Synchronized Queue? Pin
JoeRip15-Aug-08 12:33
JoeRip15-Aug-08 12:33 

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.