Click here to Skip to main content
15,891,033 members
Home / Discussions / C#
   

C#

 
GeneralRe: How do I unit test this? [modified] Pin
Keith Barrow14-Feb-10 5:54
professionalKeith Barrow14-Feb-10 5:54 
AnswerRe: How do I unit test this? Pin
Not Active14-Feb-10 4:57
mentorNot Active14-Feb-10 4:57 
AnswerRe: How do I unit test this? Pin
Luc Pattyn14-Feb-10 5:00
sitebuilderLuc Pattyn14-Feb-10 5:00 
GeneralRe: How do I unit test this? Pin
Member 448708315-Feb-10 6:50
Member 448708315-Feb-10 6:50 
GeneralRe: How do I unit test this? Pin
Luc Pattyn15-Feb-10 11:44
sitebuilderLuc Pattyn15-Feb-10 11:44 
AnswerRe: How do I unit test this? [modified] Pin
Jimmanuel14-Feb-10 11:34
Jimmanuel14-Feb-10 11:34 
GeneralRe: How do I unit test this? Pin
Member 448708315-Feb-10 6:48
Member 448708315-Feb-10 6:48 
GeneralRe: How do I unit test this? Pin
Jimmanuel15-Feb-10 8:46
Jimmanuel15-Feb-10 8:46 
Member 4487083 wrote:
only testing public members

I'm not saying don't test them, I'm saying don't call them directly to test them. To test the private method in my example I'd write test cases that started with the public method and manipulate the inputs in order to fully exercise the private one.

Member 4487083 wrote:
a unit eg. a single method

I'd call a unit a class, not a method or a property. When I link to a third party DLL to import some functionality, I'm importing the classes not individual methods.

Member 4487083 wrote:
which may include using things in a way that they weren't necessarily supposed to be used

Of course, but I always honor the contract of the classes that I'm testing. If a class has a method that takes a string parameter I'll throw everything I can think of into that parameter to stress the method but if you go outside the contract then what are you testing? If something is private then it's not supposed to be accessible by anything other than things internal to the class so it should be tested only by way of things internal to the class.

Member 4487083 wrote:
Dead code is potentially a bug waiting to happen IMHO

I agree completely.

Member 4487083 wrote:
it may be worth making a few modifications for testing

I agree almost completely. Testability is something that can/should be built in so that no modifications are required to do it. The connection string is a good example. Ideally those should be built to be configurable from the beginning - it shouldn't have to be added on later just to accommodate testing. Still, this is something completely different from changing the accessibility level of members to facilitate testing. Making something configurable is an enhancement that promotes flexibility and testability; making something unnecessarily public makes it more testable but introduces security risks. More to the point, making a connecting string configurable doesn't change the contract of the class but changing something from private to public does.
Badger | [badger,badger,badger,badger...]

QuestionCrash inside InitializeComponent() Pin
SimpleData14-Feb-10 0:24
SimpleData14-Feb-10 0:24 
AnswerRe: Crash inside InitializeComponent() Pin
Abhinav S14-Feb-10 0:30
Abhinav S14-Feb-10 0:30 
GeneralRe: Crash inside InitializeComponent() Pin
SimpleData14-Feb-10 0:34
SimpleData14-Feb-10 0:34 
GeneralRe: Crash inside InitializeComponent() Pin
Abhinav S14-Feb-10 0:47
Abhinav S14-Feb-10 0:47 
GeneralRe: Crash inside InitializeComponent() Pin
SimpleData14-Feb-10 1:42
SimpleData14-Feb-10 1:42 
AnswerRe: Crash inside InitializeComponent() Pin
Luc Pattyn14-Feb-10 0:52
sitebuilderLuc Pattyn14-Feb-10 0:52 
GeneralRe: Crash inside InitializeComponent() Pin
SimpleData14-Feb-10 1:42
SimpleData14-Feb-10 1:42 
QuestionMy .net application stops suddenly , want to know why ? Pin
Dr.DigiTaL13-Feb-10 21:51
Dr.DigiTaL13-Feb-10 21:51 
AnswerRe: My .net application stops suddenly , want to know why ? Pin
Abhinav S13-Feb-10 22:13
Abhinav S13-Feb-10 22:13 
Questionconvert image Pin
reza kia13-Feb-10 20:41
professionalreza kia13-Feb-10 20:41 
AnswerRe: convert image Pin
dan!sh 13-Feb-10 20:51
professional dan!sh 13-Feb-10 20:51 
GeneralRe: convert image Pin
reza kia14-Feb-10 1:34
professionalreza kia14-Feb-10 1:34 
GeneralRe: convert image Pin
dan!sh 14-Feb-10 3:59
professional dan!sh 14-Feb-10 3:59 
GeneralRe: convert image Pin
reza kia14-Feb-10 21:06
professionalreza kia14-Feb-10 21:06 
QuestionHow to read an image from an .xml file can we insert an image in .xml file Pin
koganti.pardhasaradhi13-Feb-10 19:26
koganti.pardhasaradhi13-Feb-10 19:26 
AnswerRe: How to read an image from an .xml file can we insert an image in .xml file Pin
dan!sh 13-Feb-10 20:07
professional dan!sh 13-Feb-10 20:07 
GeneralRe: How to read an image from an .xml file can we insert an image in .xml file Pin
koganti.pardhasaradhi14-Feb-10 3:46
koganti.pardhasaradhi14-Feb-10 3:46 

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.