Tuesday, September 21, 2021

Monday, August 9, 2021

Wednesday, November 11, 2020

Sites for learning

“There is no end to education. It is not that you read a book, pass an examination, and finish with education. The whole of life, from the moment you are born to the moment you die, is a process of learning.” – Jiddu Krishnamurti
Sites for learning to code, software processes and more. Some are free, some have free content and some costs. 

Share:

Monday, September 21, 2020

Friday, August 3, 2012

Friday, November 18, 2011

Code coverage info from NUnit into Visual Studio

Use NCover or dotCover you might say. And you would be right.

But for the current project I was looking for a free solution. I started to google the web for a free alternative and found PartCover, OpenCover and this article.

PartCover and OpenCover does noe have any GUI or plugin in Visual Studio, so when I saw that it was possible to use the same window in VS as MSTest I was sold.

Run the following command in the visual studio prompt. (Add the correct paths and dlls for your system)

vsinstr -coverage MyLibrary.dll
start vsperfmon -coverage -output:mytestrun.coverage
nunit-console.exe /noshadow UnitTests.dll
vsperfcmd -shutdown
Whats happening here is that we are first adding instrumentation to the dll. Then we are starting the vsperfmon service to listen to whats beeing executed. Execute the test runner and shutdown the vsperfmon service.
Then open the mytestrun.coverage file in Visual Studio. Voila..

The Test coverage is displayed with the information.
I guess the only catch is that you need Team System Tools for this to work.
Off course you need to manually set this up. Hmm maybe I should write a Visual Studio plugin..

Share:

Friday, September 16, 2011

Seterlund.CodeGuard is now on NuGet

My small guard library is now available on NuGet.

The package name is Seterlund.CodeGuard and is available under the New BDS License.

The Guard.That(...) will throw an exception, when some condition is not met

public void SomeMethod(int arg1, int arg2)
{
    // This line will throw an exception when the arg1 is less or equal to arg2
    Guard.That(() => arg1).IsGreaterThan(arg2);

    // This will check that arg1 is not null and that is in some range 1..100
    Guard.That(arg2).IsNotNull().IsInRange(1,100);

    // Several checks can be added.
    Guard.That(arg1)
      .IsInRange(100,1000)
      .IsEven()
      .IsTrue(x => x > 50, "Must be over 500");

    // Do stuff
}


The Validate.That(...) method makes it possible to return a list of all error conditions

public void OtherMethod(int arg1)
{
    // Get a list of errors
    List<string> errors = Validate.That(() => arg1).IsNotNull().GetResult();
}
---
Share: