Techie: Sabarinathan Arthanari

Let's make a better world

For one of the projects, we needed a branch level code coverage report to be generated. Visual Studio 2012 supports code coverage with different unit testing frameworks. But Visual Studio is not producing the branch level code coverage details.

We are using the NUnit as unit testing framework for the project. So we analysed the different code coverage tools available for .Net projects. We found the OpenCover with ReportGenerator is the best option available with complete NUnit features (the NCover yet to support the TestCaseSource Attribute).


But it lacks IDE integration. So I found a way to generate and invoke the reports from Visual Studio toolbar.

  1. Basically the script first invokes the NUnit unit testing tool. Command line console reference :
  2. OpenCover captures the NUnit testing results and produces the coverage report in .XML format. Usage reference :
  3. ReportGenerator produces the HTML report based upon OpenCover’s Results.XML. Usage Reference :
  4. Invoke the html summary report created in coverage sub-folder


  1. Install the necessary nuget packages
  • NUnit.Runners  
  • OpenCover
  • ReportGenerator

    PM> install-package Nunit.Runners
    PM> install-package OpenCover
    PM> install-package ReportGenerator


  1. Create simple batch file to be invoked from Visual Studio.
    1. Create following .bat file in unit test project with the name Coverage.bat.
    2. Change the “Copy to Output Directory” property to “Copy always” value. This will copy the file to bin folder or unit test project.


Note: In this batch file replace OpenCover.4.5.2506, ReportGenerator. with the versions deployed in your project

REM @echo suppresses command line. ^ is line continuation character

REM $(BinDir) is VS command line parameter of bin folder path of the selected project


..\..\packages\OpenCover.4.5.2506\OpenCover.Console.exe ^

    -target:..\..\packages\NUnit.Runners.2.6.3\tools\nunit-console.exe ^

            -targetargs:”<ASSEMBLY>.UnitTest.dll /noshadow /nologo” ^

    -register:user ^

    -filter:”+[<ASSEMBLY>*]* -[<ASSEMBLY>.DataModel]* -[<ASSEMBLY>.UnitTest]* -[<ASSEMBLY>.Diagrams]*” ^

    -filter:-excludebyfile:*\*Designer.cs -mergebyhash

REM Default filters are: -[mscorlib]* -[mscorlib.*]* -[System]* -[System.*]* -[Microsoft.VisualBasic]*

REM delete old coverage files

REM /F /Q switches to delete files and directories even with readonly attribute without confirmation

DEL /F /Q .\coverage\*.*

REM Generate HTML based coverage reports

..\..\packages\ReportGenerator.\reportgenerator.exe ^

    -reports:results.xml -targetdir:coverage Verbosity: Error

REM invoke the html coverage summary in browser

START “.\coverage\index.htm”


  1. Create the External Tool entries in Visual Studio and in toolbar

Configure the “External Tools” to Coverage.Bat in bin folder as shown in below screenshot. This will execute the commands within the IDE and will display the output in Visual Studio’s “Output” window.


If you configured this as first External Tool this will be displayed as “External Command 7″ (by default visual studio has 6 external tools preconfigured). You can add this menu item to necessary toolbar (I configured to Build tool bar) as shown in below steps.



Sample output


The raspberry Pi become quite famous and sold 1.75M units, so that most of the top open source software manufacturers are trying to give support to it. The 7 different types of operating systems that can be installed in Raspberry Pi is listed in this link.

Out of this list, the Raspian is the most recommeded choice for the new users. Its extremly easy to install and use. The Raspian is Debian based Linux operating system for ARM 32 bit processors. Debian (and Ubuntu, Mint etc) is the most commonly used Linux Os for laptops and PCs. So lot of supported softwares are already available for Raspbian also.

The simplest of all is Coder OS from Google. This is also based on Raspbian and it has additional applications (web server and web based development applications) pre-installed.

It’s a free piece of software that turns a Raspberry Pi into a simple, tiny, personal web server and web-based development environment–just what you need for crafting HTML, CSS, and Javascript while you’re learning to code. It just takes ten minutes to set up and you’re ready to start experimenting with building real web stuff.



  1. The installation of the OS is straight forward. Download the OS from the Coder site and write the image to SD Card.
  2. Just unzip the downloaded file. You will end up with a folder called coder_<versionno>. Inside that folder, there’s another folder called coder_<versionno> and under that, is an SD card image file called raspi.img.
  3. Windows Users: To write the image to SD Card download the Win32DiskImager utility (it is a portable zip file). You may need to run the utility as Administrator! Right-click on the file, and select ‘Run as Administrator’ 300px-Win32DiskImagerSelect the image file you extracted above. Select the drive letter of the SD card in the device box and click Write. Be careful to select the correct drive; if you get the wrong one you can destroy your data on the computer’s hard disk!
    The complete instructions for other OS users can be found in following link
  4. If you are on windows download and install Bonjour Print Services (It’s just 5MB)


Connecting Raspberry Pi with the computer

1. Connecting through Hub

Connecting Raspberry Pi via hub doesn’t need any configuration at all. Just connect the Raspberry Pi to Hub. The necessary IP settings will be automatically configured via hub’s or switch’s DHCP server.

2. Direct connection to computer via LAN cable

To connect Raspberry Pi via LAN cable, the easiest choice is to configure both the PC and Raspberry Pi to use static IP addresses. The catch is Windows users can’t directly edit the contents of Raspbian/Coder files as Coder OS uses ext4 file system. This file system is not supported in Windows.

You may need to use Linux OS to edit the contents. The easiset option for Windows users is to use Virtual Box to run a Linux OS in virtual machine. To configure the IP address mount the SD card and use: sudo nano <mountpoint>/etc/network/interfaces and change the file so that it contains:

auto lo

iface lo inet loopback

iface eth0 inet static

allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

To configure DNS servers use : sudo nano <mountpoint>/etc/resolv.conf and change the file so that it contains:


Finally issue the sync command and unmount / safely remove the SD card

The DNS/nameservers mentioned above are Google’s public DNS servers. These can be configured to other open/internal DNS servers as you prefer. Here the PC will act as a gateway for Raspberry Pi. So the PC’s Network adapter should be configured with static address as well.

Static IP


Completing the installation

Once the Coder OS is installed and configured in SD card, insert it into the SD card slot on Raspberry Pi and switch on the power. After 2 minutes, browse the http://coder.local/ address in your PC browser. This should show the SSL error, ignore the warning and proceed. 1.-login-google-coder-raspberry-pi

If you are able to see the screen similar to above, you’ve configured your Raspberry Pi successfully! Congratulations !!

You may check this link to understand how to configure and work with Coder web based development environment.


If your browser unable to open the page, you may need to check Raspberry Pi is up or not and connected to the network or not. Windows user can use Advanced IP scanner software to detect the computers connected in same  network. You may download it from

If you are able to see the Coder in Results box, it means that your Raspberry is up and connected to your network. It its not detected, check your network configurations and connections.

IP Scanner


Application launcher is a light-weight tool created in C# .NET. This serves following four importnt uses.

  1. With this tool users can load multiple applications, documents and utilities (executables) with a simple mouse click. Launcher insert file
  2. Users can move the applications (low priority) from auto startup of Windows to this application. So that users can load them manually only when necessary. It will help Windows to load quickly.
  3. This application runs silently in background and displays just notification icon in Windows tray area. As Windows 8 doesn’t have Start menu, it will be helpful for Windows 8 users to quickly load the necessary applications and documents.


  4. Users can save their list of preferred files as as session so that they can be launched whenever required. It will also help users to switch between the sessions easily. This tool will be useful for the users who are using same machine(laptop/PC) for multiple purposes. For example, for the users who are using a same laptop to develop different types of applications (.NET, Java, Android etc) or for the users who are using a machine for both official and personal uses.



You can download Application Launcher tool from the following link


  • Please install this application other than the programs files folder to avoid folder security permissions issue.
  • This application is portable. The files can be copied to any other machine having .NET 2.0 and can be used.


This series of article is for the software engineers who are also interested in electronics/robotics.

1 Raspberry Pi with GPIO Raspberry Pi is the credit card size computer. We may compare it with P3 , 512 MB desktop PC system box. Few people use it as a stand alone server or computer. You may find some of the uses in the following link. I connected my external hard disk to it and I’m using it as a file server for my laptop and other PCs.

As a software engineer, my plan is to use Raspberry Pi to code high level language to learn, create and control the basic electronic/digital/robotic circuits via GPIO interface in shortest period of time.

In order to get started with the Raspberry Pi, please purchase Raspberry Pi Model B. People from Tamilnadu, India can order from Simple Labs (and for me they delivered with in 24 hours even to the remote location in Tamilnadu).

Price of Raspberry Pi in India as of 19th September 2013 is,

  • RASPBERRY PI – MODEL B – 512MB – Rs.3,465.00 (with free GPIO cable)
  • Low Cost Case for Raspberry Pi – Rs.262.50

Updated: 2014-Mar-22: Raspberry PI is now available @ Rs.2900/-  from Farnell

As I have a laptop, I planned to use it as headless device (means using it with remote desktop, without separate monitor, keyboard, mouse). Even for that you may need to purchase additional components, wires and connectors.

  1. SDHC memory card or Micro SD card with adapter (4 GB min/32 GB Max). Please ensure that card is of Class 10 type. As memory card will be used as permanent storage, Class 10 is essential to achieve high disk I/O performance. Cheap Class 4 type card will degrade the disk I/O performance.
    2 SD Card with Adapter
  2. 5 V 2 Amp DC adapter (1 Amp is also OK)
    • All recent model mobile phones comes with micro USB male adapter. Please check the Ampere rating, it should be at least 1 Amp (otherwise in peak power consumption, Raspberry Pi may restart)
      3 Power Adapter
    • You may connect the board to normal PC/laptop via USB to micro USB cable also. But your PC/laptop should support power ratings as mentioned above
      4 micro USB cable
  3. RJ 45 network cable to connect with Laptop/PC/Hub/Switch
    5 Rj 45 cable
  4. (optional) Normal mobile earphone to listen audio from raspberry
    6 Earphone

Connecting the wires/components is straight forward process. If you need detailed description please check the following references

  1. RPi Hardware Basic Setup
  2. FAQs

Assembling the case

0 1 case FZ0379-10

Raspberry Pi ports

0 2 Raspi-Model-AB-Mono-1-699x1024

Assembled Raspberry Pi

7 Setup

 The next part in this series will be installing the OS. Meanwhile  please check the video of Hello World output from Raspberry Pi GPIO using C Language

References and links

You can find more information about the Raspberry Pi at its distributor Farnell element14… .


I’ve recently used Sparx’s Enterprise Architect (EA) tool for one of my projects to create various design diagrams (use-case diagrams, activity diagrams, sequence diagrams and class diagrams etc.). While the tools like Visio are able to produce data models and class structures for conventional programming languages, in addition to that,  EA can be used to create data models and diagrams for frameworks like SharePoint too.

In EA, user can create new data types for their frameworks and the data types can be mapped against the conventional SQL data types. I was able to generate the SharePoint list logical data models using that feature.

  • The important feature of Sparx is, It’s able to import the code from the .NET source files and generates the class structures.
  • The graphical representations of elements (objects) and connectors are beautiful and it supports different output formats like BMP, PNG, JPG and PDF etc.
  • Its having powerful automation functionality which are exposed via COM. Programmers can automate the repetitive tasks of Sparx via VBScript, JavaScript, VB6, .NET etc.

Here is the script to automate the creation of images from the diagrams created with single mouse click. This VBScript code is based up on the sample script mentioned at following link


option explicit
!INC Local Scripts.EAConstants-VBScript

‘ Global reference to the current project interface
dim projectInterface as EA.Project
dim foldername

‘ Show the script output window
Repository.EnsureOutputVisible “Script”
foldername = “c:\\temp\\”

sub ExportAllDiagrams()
    ‘ Show the script output window
    Repository.EnsureOutputVisible “Script”

    set projectInterface = Repository.GetProjectInterface()
    ‘ Iterate through all model nodes
    dim currentModel as EA.Package
    for each currentModel in Repository.Models

        ‘ Iterate through all child packages and save out their diagrams
        dim childPackage
        for each childPackage in currentModel.Packages
            DumpDiagrams childPackage, foldername

    Session.Output “Done!” 
end sub

‘ Recursively saves all diagrams under the provided package and its children

sub DumpDiagrams ( thePackage, byval subfoldername )

    ‘ Cast thePackage to EA.Package so we get intellisense
    dim currentPackage as EA.Package
    set currentPackage = thePackage
    dim newfoldername
    newfoldername = trim(replace( replace( thePackage.Name, “:”, “”), “.”, “”))
    if newfoldername <> “” then
        ‘ Save and close the diagram
        subfoldername =  subfoldername + newfoldername  + “\\”
        CreateFolder subfoldername
    end if
    ‘ Iterate through all diagrams in the current package
    dim currentDiagram
    dim filename
    for each currentDiagram in currentPackage.Diagrams

        filename = trim(replace( replace( currentDiagram.Name, “:”, “”), “.”, “”))
        if filename <> “” then
            ‘ Open the diagram
            Repository.OpenDiagram( currentDiagram.DiagramID )
            projectInterface.SaveDiagramImageToFile GetFilename(subfoldername ,filename + “.png”, 1)
            Repository.CloseDiagram( currentDiagram.DiagramID )
        end if

    ‘ Iterate through all diagrams in the sub package
    dim childPackage ‘as EA.Package
    for each childPackage in currentPackage.Packages
        DumpDiagrams childPackage, subfoldername
end sub

Function GetFilename(thefoldername, theFilename, byval thesequence )
   Dim fso, f
   Set fso = CreateObject(“Scripting.FileSystemObject”)
        dim nametocheck
           if thesequence = 1 then
            nametocheck = thefoldername + theFilename
            nametocheck = thefoldername + cstr(thesequence) + theFilename
        end if
   If fso.FileExists(nametocheck) Then
        GetFilename = GetFilename(thefoldername, theFilename, thesequence + 1 )
        if thesequence = 1 then
            GetFilename = thefoldername + theFilename
            GetFilename = thefoldername + cstr(thesequence) + theFilename
        end if
   End if
End Function

Function CreateFolder( theFolder )
   Dim fso, f
   Set fso = CreateObject(“Scripting.FileSystemObject”)
   If not fso.FolderExists(theFolder) Then
    Set f = fso.CreateFolder(theFolder)
  End if
End Function


What is MVC ?

  • MVC is an architectural design pattern.
  • It separates business logic (Model), UI design (View), UI Events & Control flow (Controller) from each other.
  • I helps to produce better unit testable code for all the above 3 layers.


How to implement it in ASP.NET ?

ASP.NET MVC is a new framework for building Web applications based up on MVC pattern. Its using ASP.NET Routing techniques to identify the controller to invoke from the variables passed in URL and form data.


Visual Studio 2008 or above

.NET Framework 3.5 SP1 or above

ASP.NET MVC library

Create a New Project


Select Empty template in Project Template screen and press OK button

Application Structure

Default Application Structure


Place all your controller classes in /Controllers folder
Place all your UI page designs in /Views folder and its sub-folders
Place all your business logic class files in /Models folder
Place all your JavaScript files(including jQuery) in /Scripts folder
Place all your CSS, images in /Content folder


Steps to create a Data List

1. Create a controller

1. Right click on Controllers Folder and Select Add –> Controller menu


2. Select controller name as “HomeController” as default controller of MVC


3. This will automatically create a class file with name “HomeController.cs”

namespace Mvctest1.Controllers
    public class HomeController : Controller
        // GET: /Home/

        public ActionResult Index()
            return View();


4. As we notice all controllers are derived from System.Web.Mvc.Controller.

The MVC classes are defined in Assembly System.Web.Mvc.dll which are normally installed in
C:\Program Files\Microsoft ASP.NET\ASP.NET MVC 3\Assemblies\System.Web.Mvc.dll

5. Action Definition

Visual studio creates default member function “Index” which return value is “System.Web.Mvc.ActionResult”.
The controller contains one or more “Actions” which performs units of functionality.

2. Create a Model

Model is nothing but business object. We can use our traditional data access mechanism like LINQ to SQL, LINQ to Entities, Enterprise Library etc. For this example, I’m going to use Northwind database with LINQ to SQL.

1. Right click on Models Folder and Select Add –> New Item… and create a LINQ to SQL file (dbml)
2. Set the namespace values of dbml file as <ProjectNamespace>.Models to be automatically picked by MVC framework


3. Connect your database with “Server Explorer”.


4. Drag and drop your table/view which contains data to list to dbml designer.

5. Build the Project to update the project assembly with class files generated by LINQ to SQL file.

3. Create a View

1. Right click on the name of Action name in HomeController class and select “Add View…” menu


2. Visual Studio will show “Add View” dialog box with View name automatically identified from “Action name”.

3. Select Create a strongly-typed view check box.

4. Select your entity name listed in “Model class” list box. For this example “Sales_Totals_by_Amount (Mvctest1.Models)”

5. Select “List” in Scaffold template as we are creating list type web page.

6. Use “~/Views/Shared/_Layout.cshtml” as layout or master page. (this master page is created by Visual Studio automatically”

7. Visual Studio will create a new view in <ProjectFolder>\Views\Home\Index.cshtml location.
Here Home is the controller name and Index is the view name.


4. Integrating Model and View with Controller

In controller action method fetch rows through LINQ to SQL entities and pass to the view as below.

        public ActionResult Index()
            using (Mvc3ApplicationSample.Models.NorthWindDataContext dc = 
                new Models.NorthWindDataContext())
                var query = from row  in dc.Sales_Totals_by_Amounts
                                select row;

                //The following line call the View engine to render "Index" view
                //with the populated data list
                return View("Index"
                    ,  query.ToList<Mvc3ApplicationSample.Models.Sales_Totals_by_Amount>()

5. Compile and run the project. Browser will display the “Sales Totals by Amount” data list page.



  1. Download Express edition
  2. Download ASP.NET MVC




  1. All data and information provided on this page is for informational purposes only. Some parts of this tutorial are taken from the specified links and references. The mentioned writings belong to their corresponding authors.
  2. The opinions expressed herein are my own personal opinions and do not represent my employer’s view in any way.



We know getting the selected text from a HTML page is a basic thing. But I think the code is not widely available. The JavaScript code below fetches the value anywhere in a page including textarea, input and text fields of the forms.

function GetSelectedText()
  var selectedText=(
 if(!selectedText || selectedText=="")
     selectedText = document.activeElement.value.substring(
          . document.activeElement.selectionEnd);
 return selectedText;


Here are the bonus bookmarklets for the dictionaries for English and Tamil.

//English Dictionary
javascript:var%20newfunc=function%20a(){q=window.getSelection?window.getSelection():document.getSelection?document.getSelection():document.selection.createRange().text;if(!q||q==""){if(document.activeElement.selectionStart){q= document.activeElement.value.substring(document.activeElement.selectionStart,document.activeElement.selectionEnd)}}if(!q||q=="")q=prompt("Enter%20term:");if(q!=null)""+q)}()

//English to Tamil
javascript:var%20newfunc=function%20a(){q=window.getSelection?window.getSelection():document.getSelection?document.getSelection():document.selection.createRange().text;if(!q||q==""){if(document.activeElement.selectionStart){q= document.activeElement.value.substring(document.activeElement.selectionStart,document.activeElement.selectionEnd)}}if(!q||q=="")q=prompt("Enter%20word:");if(q!=null)''+q)}()


//Tamil to English
javascript:var%20newfunc=function%20a(){q=window.getSelection?window.getSelection():document.getSelection?document.getSelection():document.selection.createRange().text;if(!q||q==""){if(document.activeElement.selectionStart){q= document.activeElement.value.substring(document.activeElement.selectionStart,document.activeElement.selectionEnd)}}if(!q||q=="")q=prompt('Enter%20word%20in%20Tamil:');if(q!=null)''+q)}()


The following script helps to identify the recently modified objects in a database.

The SQL Server 2005 and onwards keeps the object information in sys.objects.

  1. Types holds the type of object. The type “S” means system objects.
  2. create_date column holds the object creation date and time
  3. modify_date column holds the last modified date and time


The following script fetches the objects modified or created for last 25 days

SELECT name, create_date, modify_date,type
    FROM sys.objects
         type != ‘S’
         ( DATEDIFF(D,modify_date, GETDATE()) < 25) OR
         ( DATEDIFF(D,create_date, GETDATE()) < 25)
    ORDER BY  create_date, modify_date


The serious of articles in this blog is focused to provide queries to optimize the SQL Server design quickly.

The Original tips mentioned in following pages


IMPACT : Slows down execution

If a stored procedure name begins with “SP_,” then SQL server looks for a stored procedure beginning with "sp_" in the following order:
    MASTER system database
    use FQN (Fully Qualified Name) to locate the SP
    if FQN is not supplied, current database is used with dbo as owner

Searching in the master database causes extra overhead and even a wrong result if another stored procedure with the same name is found in master database.



Rename the stored procedures


Query To Identify the Stored Procedures

Execute following Query in your SQL Server database to list the names of procedures those starts with sp_.



If Database diagrams enabled in database use may need to use following query



The serious of articles in this blog is focused to provide queries to optimize the SQL Server design quickly.

The Original tips mentioned in following pages


IMPACT : Slows down execution

With every SELECT and DML statement, the SQL server returns a message that indicates the number of affected rows by that statement. This information is mostly helpful in debugging the code, but it is useless after that.



For stored procedures that contain several statements or contain Transact-SQL loops, setting SET NOCOUNT to ON can provide a significant performance boost because network traffic is greatly reduced.


Query To Identify the Stored Procedures

Execute following Query in your SQL Server database to list the names of procedures those doesn’t include SET NOCOUNT commands.