How to specify namespaces to run in NUnit-Console?

Posted in Uncategorized on November 8th, 2011 by schrodinger – Be the first to comment

It is useful when you have unit tests, integration tests, functional tests in the same test project but under different namespaces such as
/NUnitTests.UnitTests
/NUnitTests.IntegrationTests
/UnitTestss.FunctionalTets

1. Open up CMD.exe and CD to C:\Program Files (x86)\NUnit 2.5.10\bin\net-2.0

2. Input:
nunit-console Path_To_NUnitTests.dll /run=NUnitTests.UnitTests,NUnitTests.IntegrationTests
Or
nunit-console Path_To_NUnitTests.dll /run:NUnitTests.UnitTests,NUnitTests.IntegrationTests

The only thing you need to be careful here is that do not leave space between the namespaces!

http://www.nunit.org/index.php?p=consoleCommandLine&r=2.5.9

Share

fastest way to delete large folders in windows?

Posted in Windows7 Tips & Tricks on October 24th, 2011 by schrodinger – Be the first to comment

The answer from the stackoverflow question is very useful.

http://stackoverflow.com/questions/186737/whats-the-fastest-way-to-delete-a-large-folder-in-windows/6208144#6208144

del /f/s/q foldername > nul
rmdir /s/q foldername
Share

Git For Windows Developer

Posted in Git on October 5th, 2011 by schrodinger – Be the first to comment

Git For Windows Developer

Just some links that I think are useful in my journey to use Git in Windows.

http://help.github.com/linux-set-up-git/

http://lostechies.com/jasonmeridth/2009/06/01/git-for-windows-developers-git-series-part-1/

https://github.com/github/gitignore

http://gitref.org/

Git-TFS bridge: https://github.com/spraints/git-tfs

Visual Studio Git plugins:

http://gitscc.codeplex.com/

http://code.google.com/p/gitextensions/

Share

Introduction to PetaPoco – .NET micro ORM framework

Posted in ORM, PetaPoco on October 5th, 2011 by schrodinger – Be the first to comment

PetaPoco seems to be a very nice little micro ORM framework, I have given a try to create some demo for it. It seems to be relatively easy to use besides the T4 template may not be that straightforward if you have not never used it before.

1. Install the latest Nuget
Get it from http://nuget.org/ and install it to your VS2008/2010

2. Install the PetaPoco package via Nuget

Right click the Project root in the Visual Studio

Search for PetaPoco package

After installed the package, it will generate a few files under the /Models folder

3. Add the connection string in the web.config, in my case, it is a connection string to the MS Northwind database.

<add name="NorthwindConnection" connectionString="data source=.;Initial Catalog=Northwind;Integrated Security=SSPI;" providerName="System.Data.SqlClient" />

4. Add ConnectionStringName = “NorthwindConnection“; to the Database.tt T4 template file
under /Models/Generated folder, and save the change, the T4 generator will generate all of the database Poco classes
in the Database.cs file.

5. Add a CustomerController, Customer Index view and CustomerModels for demonstrating the PetaPoco magic.

    Model:

    public class CustomerModel
    {
        public IEnumerable<Customer> GetCustomers()
        {
            var db = new PetaPoco.Database("NorthwindConnection");
            return db.Query<Customer>("SELECT * FROM Customers");
        }
    }

   View Action:

   public ActionResult Index()
   {
       var cm = new CustomerModel();
       ViewBag.Customers = cm.GetCustomers();
       return View();
   }

   Razor View:

   @model NorthwindConnection.Customer

   @{
      ViewBag.Title = "Customer";
    }

   <h2>Customer List</h2>
   <table>
    @foreach (var c in ViewBag.Customers)
    {
        <tr>
            <td>@c.CustomerID</td>
            <td>@c.CompanyName</td>
            <td>@c.ContactName</td>
            <td>@c.Phone</td>
        </tr>
    }
   </table>

You can download the sample project from:

https://github.com/lqj/PetaPocoMVC-Sample

References:
tangible T4 Editor plus modeling tools for VS2010:

http://visualstudiogallery.msdn.microsoft.com/60297607-5fd4-4da4-97e1-3715e90c1a23

T4 Editor plus tangible modeling tools for VS2008:

http://visualstudiogallery.msdn.microsoft.com/1A6C4FB2-7908-4721-92B3-61F2CEE92294

Share

.NET ORM frameworks

Posted in .NET, ORM on October 4th, 2011 by schrodinger – Be the first to comment

Microsoft stack:
Linq to SQL
Entity Frameworks

Open Source:
NHibernate/FluentNHibernate
Subsonic
PetaPoco
Massive
Dapper

Commercial:
Lightspeed

Generic Repository Frameworks:

http://code.google.com/p/genericrepository/

Note:
You can install PetaPoco from the Nuget, if you have encountered error when installing via Nuget “The ‘schemaVersion’ attribute is not declared.” It probably means you have an old version of Nuget, visit http://nuget.org/ and install the latest version.

References:

http://stevenhollidge.blogspot.com/2011/04/how-to-use-dapper-petapoco-micro-orms.html

http://huyrua.wordpress.com/2010/07/13/entity-framework-4-poco-repository-and-specification-pattern/

Entity Framework Profiler

Share

Selenium2 WebDriver Introduction

Posted in Selenium2 on September 29th, 2011 by schrodinger – Be the first to comment

The Selenium2 WebDriver has some exciting features compared to Selenium 1. You can find more details on the Selenium offical blog release blog about Selenium2!

1. New WebDriver APIs for Python, Ruby, Java and C#, PHP, Perl, WebkitDriver.
2. Fast (no need to run RC server anymore), stable and a lot of bug fixes.
3. IE(6-9)/Firefox(3,4,5,6,7)/Chrome/Opera support
More…

You can download the dotnet webdriver API from:

http://code.google.com/p/selenium/downloads/list

If you are using InternetExploreDriver, you need to modify some security settings, which you can find out more from this wiki page.

On IE 7 or higher on Windows Vista or Windows 7, you must set the Protected Mode settings for each zone to be the same value. The value can be on or off, as long as it is the same for every zone. To set the Protected Mode settings, choose “Internet Options…” from the Tools menu, and click on the Security tab. For each zone, there will be a check box at the bottom of the tab labeled “Enable Protected Mode”.
The browser zoom level must be set to 100% so that the native mouse events can be set to the correct coordinates.

I have created a really basic C# library project when playing with selenium2 webdriver, you can download it from: Selenium2Sample

For migrating from Selenium1 to Selenium2, you can take a look at:

http://seleniumhq.org/docs/appendix_migrating_from_rc_to_webdriver.html#migrating-to-webdriver-reference

There are some links below that I found quite helpful along the way.

http://seleniumhq.org/docs/03_webdriver.html

http://seleniumhq.org/docs/04_webdriver_advanced.html

http://code.google.com/p/selenium/wiki/GettingStarted

http://code.google.com/p/selenium/wiki/NextSteps

http://code.google.com/p/selenium/wiki/InternetExplorerDriver

http://code.google.com/p/selenium/wiki/ArchitecturalOverview

http://java.dzone.com/articles/selenium-2web-driver-land

http://code.google.com/p/design-of-selenium-tests-for-asp-net/

http://seleniumexamples.com/blog/tag/selenium-2/

Share

CSharp – demystify @”string” symbol

Posted in .NET, C# Tips & Tricks on September 28th, 2011 by schrodinger – Be the first to comment

@ symbol is quite handy in csharp when you want to paste a file path or multiple lines of sql queries etc. Such as

string path = @”c:\temp\hello.txt”;
string path2 = “c:\\temp\\hello.txt”;

The above two lines of code produce the same result, which is the same as path2.

Now let’s see an example for multiple lines of string concatenation.

static void Main(string[] args)
{
    StringsCompare();
}

private static void StringsCompare()
{
  string a = @"SELECT * FROM TABLE
WHERE 1 = 1";
  string b = "SELECT * FROM TABLE\\r\\n" + "WHERE 1 = 1";
  Console.WriteLine("a: \\r\\n" + a);
  Console.WriteLine("b: \\r\\n" + b);
  Console.WriteLine();
  Console.WriteLine(a == b);
}

The @ symbol is a complier feature which result the same constant string as using + sign to concatenate strings together.
Following is the result of the decompiling the above code using the ILSpy:

private static void StringsCompare()
{
  string a = "SELECT * FROM TABLE\\r\\nWHERE 1 = 1";
  string b = "SELECT * FROM TABLE\\r\\nWHERE 1 = 1";
  Console.WriteLine("a: \\r\\n" + a);
  Console.WriteLine("b: \\r\\n" + b);
  Console.WriteLine();
  Console.WriteLine(a == b);
}
Share

Install rails3 in ubuntu 11.10

Posted in Rails on September 18th, 2011 by schrodinger – Be the first to comment

pres ctrl+alt+t to open terminal and then:
1. sudo apt-get install ruby1.9.2-full
2. sudo gem install rails –no-ri –no-rdoc
(file not found ‘lib’ issue)

restart the terminal after installing and check
ruby -v
rails -v

Output:
1.9.2p290
Rails 3.1.0

Share

node.js and CoffeeScript compiler for Windows

Posted in CoffeeScript, nodejs on September 15th, 2011 by schrodinger – Be the first to comment

1. You now can use the windows build for nodejs, Windows Executable: http://nodejs.org/dist/v0.5.6/node.exe
Download it and copy the sample js code from the nodejs.org

var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(1337, "127.0.0.1");
console.log('Server running at http://127.0.0.1:1337/');

Save as test.js then in cmd.exe, type: node test.js then you will get the following output.

Server running at http://127.0.0.1:1337/

Open http://127.0.0.1:1337/ in your browser then you will see ‘Hello World’ on the page.

2. Also you can also try the CoffeeScript compiler for Windows as well.
Go to https://github.com/alisey/CoffeeScript-Compiler-for-Windows, download the coffee.exe, and set the coffee.exe folder path to the environment PATH variable and you are good to go!

Reference:

http://nodejs.org/

http://npmjs.org/

http://nodetuts.com/

http://blog.tatham.oddie.com.au/2011/03/16/node-js-on-windows/

https://github.com/alisey/CoffeeScript-Compiler-for-Windows

https://github.com/joyent/node/wiki

https://github.com/joyent/node/wiki/Building-node.js-on-Cygwin-%28Windows%29

Share

How to use typeperf.exe to collect a particular process performance data

Posted in Performance Testing on August 31st, 2011 by schrodinger – Be the first to comment

It is always easy once you figure it out.

typeperf “\Process([process name])\*” to monitor a particular process in your system. For instance, typeperf “\Process(cmd)\*” or typeperf “\Process(cmd)\Working Set” or typeperf “\Process(cmd)\% Processor Time” etc, but it is not really readable unless you only need to see some particular counter like Working Set. Otherwise you should use perfmon.exe GUI tool for more complicated scenario like scheduled performance data collection and adding more counters etc.

Share