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

C#

 
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 
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 
You don't test private methods normally. DoStuff() method is hard to test as it has dependencies with other methods. You can use Interaction testing[^] to test DoStuff() method. You should refactor the dependencies to separate classes and just test it calls the expected methods. You have to use mock objects to do this. I suggest you to look at RhinoMocks, a mocking framework.

In the ExecProc() methods you have used ADO.NET classes which is hard to test. So you need to abstract it behind and interface, mock the interface while testing. Check the following,
class ProcedureExecution
{
     IDataAccess dataAccess;
     public ProcedureExecution(IDataAccess dataAccess)
     {
         this.dataAccess = dataAccess;
     }

     public void ExecProc(int vidID)
     {
          try
          {
              dataAccess.Execute("blah",vidID);
          }
          catch (Exception e)
          {
              //Console.WriteLine("error: " + e.ToString());
          }
     }
}
We have abstracted the SQL execution code behind an interface named IDataAccess and we supply it through constructor. It is called dependency injection. While testing you can easily mock IDataAccess. AFAIK, there is no testing required for the above said method as there is nothing to test. Also using static will make testing tough.

If the shown code is your data layer code, then test your method itself and check the values in the database. It's tedious, but it drives out of bugs.

All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia

How to use google | Ask smart questions

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 
GeneralRe: Do I still need to LOCK a Synchronized Queue? Pin
Wendelius15-Aug-08 12:43
mentorWendelius15-Aug-08 12:43 

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.