As I'm using NUnit more and more (i really started to fall in love with the whole unit-test concept), i find it sometimes useful to be able to debug while running the unit-test. Turns out to be quite easy. This is how it's done:
1) Put your unit-tests into separate project (I do that anyway to keep the NUnit out of "live" references) and compile it (make it either exe or dll, no difference).
2) Start NUnit, browse the compiled dll/exe (from step 1), select "File -> Save as" and save the nunit project. I typically save it in the project's root as "myproject.nunit".
3) Open the project's properties, "Debug" tab.
4) Set "Start Action" to "Start external program:" and browse the "nunit.exe" (e.g. c:\program files\nunit 2.4.1\bin\nunit.exe)
5) Set in the "Start Options" the "Command line arguments" to point to the nunit project you created in step 2. If you did the same as me, i.e. saved it in the project's root, the path should be something like "..\..\myproject.nunit"
And that's it! Just run the debug with F5 as usuall and it'll open NUNIT environment. Set break-points wherever you need in the code and run the appropriate test...
Thursday, October 11, 2007
Monday, October 08, 2007
VS 2005 - error while loading form into designer
I get this error quite frequently:
One or more errors encountered while loading the designer. The errors are listed below. Some errors can be fixed by rebuilding your project, while others may require code changes. TypeLoad failure. Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
Aparently, it's a problem in VS and there's a hotfix available for it. Restarting studio works as well, which is what I do.
One or more errors encountered while loading the designer. The errors are listed below. Some errors can be fixed by rebuilding your project, while others may require code changes. TypeLoad failure. Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
Aparently, it's a problem in VS and there's a hotfix available for it. Restarting studio works as well, which is what I do.
Friday, October 05, 2007
Backup data using ROBOCOPY
Need to set up some way of making backups of data from my drive. There's a ROBOCOPY utility in the Win2003 Resource Kit which should do the trick. I found even Robocopy GUI, which generates the script for you. Once you have the CMD file, just put it into scheduler.
Thursday, October 04, 2007
Overriding operators in C#
In one of my projects, i thought i'd love to use operators like ==, !=, > and < style="color: rgb(51, 51, 255);font-size:85%;" > public static bool operator ==(BaseEventVO evt1, BaseEventVO evt2)
{
return (((object)evt1 == (object)evt2) || ((object)evt1 != null) && ((object)evt2 != null) && evt1.IdSeq == evt2.IdSeq && evt1.Year == evt2.Year);
}
public static bool operator !=(BaseEventVO evt1, BaseEventVO evt2)
{
return !(evt1 == evt2);
}
public static bool operator >(BaseEventVO evt1, BaseEventVO evt2)
{
return (evt1.Year > evt2.Year || (evt1.Year == evt2.Year && evt1.Day > evt2.Day));
}
public static bool operator <(BaseEventVO evt1, BaseEventVO evt2)
{
return (evt1.Year < evt2.Year || (evt1.Year == evt2.Year && evt1.Day < evt2.Day));
}
Notice the cast to "(object)evt1 != null" - it is necessary in order to prevent loopback - you can't do "evt1 != null" as it'd use the "!=" overridden operator, hence ending in effective infinite loop (until call-stack blows).
You may also want to override GetHashCode() to produce unique ID of the object - speeds up things very significantly when you do hashtable lookups.
{
return (((object)evt1 == (object)evt2) || ((object)evt1 != null) && ((object)evt2 != null) && evt1.IdSeq == evt2.IdSeq && evt1.Year == evt2.Year);
}
public static bool operator !=(BaseEventVO evt1, BaseEventVO evt2)
{
return !(evt1 == evt2);
}
public static bool operator >(BaseEventVO evt1, BaseEventVO evt2)
{
return (evt1.Year > evt2.Year || (evt1.Year == evt2.Year && evt1.Day > evt2.Day));
}
public static bool operator <(BaseEventVO evt1, BaseEventVO evt2)
{
return (evt1.Year < evt2.Year || (evt1.Year == evt2.Year && evt1.Day < evt2.Day));
}
Notice the cast to "(object)evt1 != null" - it is necessary in order to prevent loopback - you can't do "evt1 != null" as it'd use the "!=" overridden operator, hence ending in effective infinite loop (until call-stack blows).
You may also want to override GetHashCode() to produce unique ID of the object - speeds up things very significantly when you do hashtable lookups.
Saturday, September 29, 2007
Number Formatting in C# using String.Format
Just so that i remember it next time. Number formatting examples (for US english):
double x = 12345.6789;
String.Format("{0:n0}") ... 12,345
String.Format("{0:n1}") ... 12,345.6
etc...
double x = 12345.6789;
String.Format("{0:n0}") ... 12,345
String.Format("{0:n1}") ... 12,345.6
etc...
Thursday, September 27, 2007
Vaccination for Peru
When travelling to Peru, you'll need following:
Oh well, better be safe than sorry i guess...
To check current situation about travel health issues, goto CDC - especially the malaria is quite important.
- Tetanus
- Typhoid
- Hep A (if you do 2nd shot within a year, you get 10yrs immunity)
- Yellow fever
Oh well, better be safe than sorry i guess...
To check current situation about travel health issues, goto CDC - especially the malaria is quite important.
Recording video (AVI/SFW)
I'm doing quite a bit of demos lately and it's starting to take way too much time. Same with writing "how-to's" for new releases. So I decided to record short sessions where I demo how to use the software and ship them along with the ClickOnce deploy. Pretty sweet I must say and users seem to like it as well.
I'm using CamStudio - excellent tool, supports regions, converions, annotation, audio recording, etc. simply great!
I'm using CamStudio - excellent tool, supports regions, converions, annotation, audio recording, etc. simply great!
Subscribe to:
Posts (Atom)