Click here to Skip to main content
15,887,477 members
Home / Discussions / C#
   

C#

 
Questionwhy i can't run a c# app on win 2k without .net framework installed? Pin
jl_araya3-Jul-04 12:32
jl_araya3-Jul-04 12:32 
AnswerRe: why i can't run a c# app on win 2k without .net framework installed? Pin
Stefan Troschuetz3-Jul-04 13:00
Stefan Troschuetz3-Jul-04 13:00 
AnswerRe: why i can't run a c# app on win 2k without .net framework installed? Pin
Tom Larsen3-Jul-04 19:59
Tom Larsen3-Jul-04 19:59 
Generalthanx! Pin
jl_araya4-Jul-04 12:51
jl_araya4-Jul-04 12:51 
Generalnoob question about classes Pin
pidhead3-Jul-04 9:20
pidhead3-Jul-04 9:20 
GeneralRe: noob question about classes Pin
Colin Angus Mackay3-Jul-04 12:18
Colin Angus Mackay3-Jul-04 12:18 
GeneralRe: noob question about classes Pin
pidhead3-Jul-04 12:58
pidhead3-Jul-04 12:58 
GeneralRe: noob question about classes Pin
Colin Angus Mackay3-Jul-04 15:38
Colin Angus Mackay3-Jul-04 15:38 
pidhead wrote:
My case is where I have a form with a text box, and I create an instance of a class to do some processing on an input file. I would like to send feedback and debug info back to the form to be displayed in a textbox.

I'm not sure that is really the best way to test the class. Even if you are not into "serious testing yet". Take a look at some of the classes available in the System.Diagnostics namespace and you'll find a number of features of .NET that help you test your code.

You can use Debug.WriteLine to send information to the OutputWindow in VS.NET which will provide a much more efficient solution, especially as you seem to want to get information out from within the class's code, rather than just checking return values.

I still recommend taking a look at nUnit because it does what you are trying to achieve in a more structured way. Also, it allows you to selectively choose which tests to run or you can run the tests over the whole system so you can check if any recent changes broke other code elsewhere you didn't expect to be affected (I common occurrance for all developers, and even more so if you are new to programming).

To get back to what you actually asked for:
pidhead wrote:
How can I do that cleanly without having to explicitly know what object in the form I'm sending the data to?

Is an event the way to do this?


You already knew the answer as your second question answers your first. Yes, you can use an event in this senario. But remember you won't be sending information directly to the object in the form, but to an event handling method that will receive the event and that will alter the control for you. After all, the TextBox or whatever knows nothing of your event.

Finally, (sorry, I'm going to get back on my writing-clean-code-for-the-situation-is-the-most-important-thing hobby-horse again) do you really want to load up your class with events that are only used for testing. What will happen to all these events being fired when you're done with testing? Okay, so they won't go anywhere but they will slow the code down, and encasing them in #ifdef #endif blocks so that you omit them when not testing is going to make the code almost unreadable.




"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar

The Second EuroCPian Event will be in Brussels on the 4th of September

Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!

My Blog


QuestionAfter close MemoryStream, how to open it to read again? Pin
god4k3-Jul-04 7:17
god4k3-Jul-04 7:17 
AnswerRe: After close MemoryStream, how to open it to read again? Pin
Steven Campbell3-Jul-04 7:52
Steven Campbell3-Jul-04 7:52 
QuestionRetrieve machine names and/or IP's ..? Pin
Adel83k3-Jul-04 6:36
Adel83k3-Jul-04 6:36 
AnswerRe: Retrieve machine names and/or IP's ..? Pin
Heath Stewart5-Jul-04 6:17
protectorHeath Stewart5-Jul-04 6:17 
GeneralIDisposable, destructors and loaded assemblies Pin
Boaz V3-Jul-04 5:01
Boaz V3-Jul-04 5:01 
GeneralRe: IDisposable, destructors and loaded assemblies Pin
KevinMac4-Jul-04 9:27
KevinMac4-Jul-04 9:27 
Generaldouble buffering Pin
blankg3-Jul-04 4:43
blankg3-Jul-04 4:43 
GeneralRe: double buffering Pin
Heath Stewart5-Jul-04 6:23
protectorHeath Stewart5-Jul-04 6:23 
GeneralCRC check Pin
kratchkov3-Jul-04 3:51
kratchkov3-Jul-04 3:51 
GeneralRe: CRC check Pin
Paul Lyons3-Jul-04 4:38
Paul Lyons3-Jul-04 4:38 
GeneralRe: CRC check Pin
Vega023-Jul-04 4:39
Vega023-Jul-04 4:39 
Generalusing System.Runtime.Serialization.Formatters.Soap; Pin
ABean2-Jul-04 23:49
ABean2-Jul-04 23:49 
GeneralRe: using System.Runtime.Serialization.Formatters.Soap; Pin
Colin Angus Mackay3-Jul-04 0:38
Colin Angus Mackay3-Jul-04 0:38 
GeneralTextBox at run time Pin
saud_a_k2-Jul-04 22:52
saud_a_k2-Jul-04 22:52 
GeneralRe: TextBox at run time Pin
Stefan Troschuetz3-Jul-04 13:16
Stefan Troschuetz3-Jul-04 13:16 
GeneralRe: TextBox at run time Pin
saud_a_k5-Jul-04 2:18
saud_a_k5-Jul-04 2:18 
GeneralRe: TextBox at run time Pin
Stefan Troschuetz5-Jul-04 2:53
Stefan Troschuetz5-Jul-04 2:53 

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.