i am rommel

Starting to write my own history

   Jun 30

Iisang Bangka Project

Another open-source project under OnePiece umbrella that focuses on Team Management! The “Iisang Bangka” is the title of another hit Filipino musician “The Dawn”. It mainly focuses on the proper management, coordination, unity, separation of concerns of a team.

I prefer to use the HTML 5 here, a two-layer application(UI and Service) on single tier architecture. I’m still using the MS stacks, ASP.NET MVC, C#, Entity Framework 4, SQL Server 2008, ExtJs and JQuery (and of course talent!)

Here are the screenshots.

I’m still working on uploading the code in Google Code, just wait for a few more days.


   Jun 27

Tindahan Ni Aleng Nena Project

Yes this is an Open Source Project for simple E-Commerce that fully fits the Philippine Market. The main purpose of this project is to fully understand the lumps of emerging technologies of Microsoft like, ASP.NET MVC, EF Code Only, Modeling, T4 Templates, WCF 4, .NET Framework 4, SQL Server 2008, Visual Studio 2010, etc. That mentioned technologies was used in this project. For now I choose the Web Platform because I’ve heard from tech prophets that web platform will be the future of IT. So I implemented the project following the HTML 5 and CSS3 standards (sorry IE your late).

You can grab it from the Google Code

If you have some time for constructive comments and suggestions, I really appreciate that.

Tindahan Ni Aleng Nena Project in Visual Studio 2010
Tindahan Ni Aleng Nena Website Preview


   Jan 07

Dependency Injection to solved unit test problem

One of the common problems with unit testing is the dependency of the SUT (systems under test) with other items/modules. So the common approach is to mock/fake this dependency. There are several frameworks that do this mocking, TypeMock, Moq, Rhinomock as some popular ones.

But sometime these dependencies can be done by simple method overload and additional class constructors. Let say for example in our QuickSaas project, we are unit testing the DataComponents and this has a lot of dependencies with the data source (database). Creating sample data and storing it onto the database and retrieving it, is not an option because it does not follow the pattern of unit testing and will just create more headaches (believe me!), so as the solution, Method Overload.

Let say we are retrieving the list of accounts and implement the paging after retrieving. Previously we have a code somewhat below.

 public virtual IList<T> GetEntities(IList<T> entities, ref Pager pager)
 {
            var returnedEntities = this.GetEntities
                               .Skip((pager.PageIndex) * pager.PageSize)
                               .Take(pager.PageSize)
                               .ToList();
            pager.TotalItems = entities.LongCount();
            return returnedEntities;
}

As you can see it is very hard to unit test this because of its dependencies to the output of GetEntities(…), so the solution is below

public virtual IList<T> GetEntities(ref Pager pager)
{
	var returnedEntities = this.GetEntities(this.GetEntities(), ref pager);
	return returnedEntities;
}
 
public virtual IList<T> GetEntities(IList<T> entities, ref Pager pager)
{
	var returnedEntities = entities
		.Skip((pager.PageIndex) * pager.PageSize)
		.Take(pager.PageSize)
		.ToList();
        pager.TotalItems = entities.LongCount();
 
	return returnedEntities;
}

And now we can freely create a unit test like below. Even though we are not really unit testing the GetEntities(ref Pager pager), it much like the same, because the implementation of GetEntities(ref Pager pager) is simply as passing the entities to GetEntities(entities, ref pager), the real core/essence of item to be tested is in GetEntities(entities, ref pager). So I think it’s fine.

[Test]
public void Test_If_Pager_Works_For_Get_Entities()
{
    using (var component = AccountDataComponent.Instance)
    {                             
        //create the reader
        var reader = new DataStub().AccountTable.CreateDataReader();
 
        //load all entities
        var entities = new List<Account>();
        while (reader.Read()) entities.Add(component.LoadEntityFromReader(reader));                        
 
        //do the paging
        var pager = new Pager(1,3 );
        var returnedEntities = component.GetEntities(entities, ref pager);
 
        //assert the values
        Assert.AreEqual(returnedEntities.Count, 1 );
        Assert.AreEqual(pager.PageIndex,1 );
        Assert.AreEqual(pager.PageSize, 3);
        Assert.AreEqual(pager.TotalPages, 2);
        Assert.AreEqual(pager.TotalItems, 4);
    }
}

And more samples…

public virtual IList<T> GetEntities(IList<T> injectedEntities)
{
    if (injectedEntities != null) return injectedEntities;
 
    IList<T> entities = null;
    try
    {
        Connection.Open();
        PrepareGetListCommand();
        using (DbDataReader rdr = Command.ExecuteReader())
        {
            entities = new List<T>();
            while (rdr.Read())
            {
                T entity = LoadEntityFromReader(rdr);
                entities.Add(entity);
            }
        }
    }
    finally
    {
        Connection.Close();
    }
    return entities;
}
 
public override IList<T> GetEntities()
{
    return GetEntities(null);
}

and another sample…

public virtual T GetEntity(int entityId, T injectedEntity)
{
    if (injectedEntity != null) return injectedEntity;
 
 
    T entity = default(T);
    try
    {
        Connection.Open();
        PrepareGetCommand(entityId);
        using (DbDataReader rdr = Command.ExecuteReader())
        {
            while (rdr.Read())
            {
                entity = LoadEntityFromReader(rdr);
            }
        }
    }
    finally
    {
        Connection.Close();
    }
    return entity;
}
 
public override T GetEntity(int entityId)
{
    return GetEntity(entityId, null);
}

Conclusion:

Sometimes the you don’t have to invest a very complicated framework, just a simple design can solved your complicated problem. Just remember the software engineer 101 motto. KISS (Keep it simple stupid) :)


   Dec 16

Creating MSDN like documentation for .Net Projects using SandCastle

The days of NDoc are over (in my opinion)! But in fairness to NDoc, this is really a great tool for generating documentation for .Net Projects ever since the SandCastle was not yet born. Today I’d downloaded this tool from Codeplex
and start working on it. Good thing there is a GUI available so I can start my QuickSaaS documentation in seconds using SandCastle. They also provided libraries, (dlls and exes) so geek programmer can work using DOS commands and also can integrate SandCastle to Nant Task.

Sandcastle produces accurate, MSDN style, comprehensive documentation by reflecting over the source assemblies and optionally integrating XML Documentation Comments. Sandcastle has the following key features:

  • Works with or without authored comments
  • Supports Generics and .NET
  • Can customize the design of generated help file (Hana, VS2005, Prototype as defaults)
  • Can generate several type of documentation (CHM, HTML, Hxs)

Here are some screenshots while I’m working with SandCastle

Figure 1: SandCastle GUI

Figure 2: Generated File Structure

Figure 3: Generated CHM on Contents tab

Figure 4: Generated CHM on Index tab

Figure 5: Generated CHM on Search Tab

 

Conclusion:

This is a very great tool, but they should think for a new logo! Every software product that is on the market should have the documentation of their API especially for those open-source and public/service projects. And we are lucky enough that the people behind this development gave us this freely. Another good point is they have this console application so I can use my NAnt task and automate the generation of documentation, just like in my case every build of QuickSaaS.


   Dec 14

GUI for Nant, the NantBuilder

Are you tired of creating Nant task using the plain old NotePad, or maybe you’re using the Visual Studio for editing the XML for NAnt, here comes the NantBuilder.

NAntBuilder is a full-featured Integrated Development Environment (IDE) for NAnt, the popular process-automating tool. It is designed to be a powerful NAnt script creator, editor, and debugger.

NAntBuilder enables you to manage your build process easily, allowing you to focus on more interesting and important works. Its full-featured code completion will save you thousands of keystrokes while authoring NAnt script. And the integrated NAnt script debugger will help you execute NAnt script task by task. With all these features, NAntBuilder provides a flexible, easy-to-use platform to author, debug and execute NAnt script.

 

 

 

Here are some screenshots using the NantBuilder when I’m creating my nant task for QuickSaas project of BlastSuites

Figure 1: Build output, when the NAnt was run

 

Figure 2: List of Task

 

Figure 3: Available NAnt Tasks

 

Figure 4: Available elements for a certain task

 

Figure 5: Visual Studio 2010 look and feel

 

Conclusion:

Even though this is not a free/open source sound, its quite useful, because I’m able to used it for 30 days for trial; and I’m only creating a heavy task for NAnt once and other updates can be done by my plain old notepad.


   Dec 09

How to debug Fitnesse Codes in Visual Studio

Fitnesse is a great tool, a fully integrated standalone wiki, and acceptance testing framework and we used this on BlastSuites projects development. During test codes/scripts creation we may encounter runtime errors that are very hard to determine/check unless we use the Visual Studio debug.

Below are the sample acceptance test pages using Fitnesse and C# code and steps how to debug test codes.








Figure 1: Fitnesse Acceptance Test Page

And here are the steps to debug acceptance that while running in Fitnesse Server.

  1. Make sure that the test runner is RunnerW.exe

  2. When you run the test a fitsharp dialog box will appear as shown below

  3. While this dialog is still open go to your Visual Studio and attached the Fitsharp process. After attaching, the Visual Studio will start in debug mode so you can now put your breakpoints and start debugging to acceptance test codes.

  4. After attaching, make sure you press the Go button in fitsharp dialog to continue the test

  5. And that’s it, the debugging now is working

Conclusion:

Developer uses test (acceptance or unit test) to check if the code is working and not buggy, but sometime the test itself has a flaw and needs to debug. The above steps are very helpful if you want to debug the Fitnesse Acceptance Test.


   Dec 09

Notepad++, NOT another notepad tool

Sometime your plain old notepad is so annoying that it just give you confusion when editing, especially when you are editing xml files (web.config, nant build files, xml configuration file, etc). The only biggest thumb up for me for notepad that’s why I continue using it is it loads fast. That was the time when Notepad++ was not in my “batman developer tool belt”.

Notepad++ is a free (as in “free speech” and also as in “free beer”) source code editor and Notepad replacement that supports several languages. Running in the MS Windows environment, its use is governed by GPL License. Based on a powerful editing component Scintilla, Notepad++ is written in C++ and uses pure Win32 API and STL which ensures a higher execution speed and smaller program size. By optimizing as many routines as possible without losing user friendliness, Notepad++ is trying to reduce the world carbon dioxide emissions. When using less CPU power, the PC can throttle down and reduce power consumption, resulting in a greener environment.

Here are the major features of Notepad++ :

  • Syntax Highlighting and Syntax Folding
  • WYSIWYG
  • User Defined Syntax Highlighting
  • Auto-completion
  • Multi-Document
  • Multi-View
  • Regular Expression Search/Replace supported
  • Full Drag ‘N’ Drop supported
  • Dynamic position of Views
  • File Status Auto-detection
  • Zoom in and zoom out
  • Multi-Language environment supported
  • Bookmark
  • Brace and Indent guideline Highlighting
  • Macro recording and playback

 

I usually use this tool when I’m editing the web.configs of QuickSaas project and when I’m setting up the Nant script for our continuous integration.


   Dec 03

Write regular CSS with your .NET apps, and then add a few variables, mixins and nested rules

120309_0242_Writeregula1.jpg

.less logo

What if you can make a dynamic CSS, include some operations (add, subtract, multiply, divide), create CSS variables, mix properties of the CSS class, and create a more compact nested CSS. That can be done by “.less” (pronounced dot-less), a .NET port of the funky ruby LESS library. We are trying/planning to implement this on our BlastSuites project QuickSaas

Here are some examples from the site.

Variables

Variables allow you to specify widely used values in a single place, and then re-use them throughout the style sheet, making global changes as easy as changing one line of code.

@brand_color: #4D926F;
#header {
  color: @brand_color;
}
 
h2 {
  color: @brand_color;
}

Operations

Are some elements in your style sheet proportional to other elements? Operations let you add, subtract, divide and multiply property values and colors, giving you the power to do create complex relationships between properties.

@the-border: 1px;
@base-color: #111;
 
#header {
  color: @base-color * 3;
  border-left: @the-border;
  border-right: @the-border * 2;
}
 
#footer {
  color: (@base-color + #111) * 1.5;
}

Mixins

Mixins allow you to embed all the properties of a class into another class by simply including the class name as one of its properties. It’s just like variables, but for whole classes

.rounded_corners {
  -moz-border-radius: 8px;
  -webkit-border-radius: 8px;
  border-radius: 8px;
}
 
#header {
  .rounded_corners;
}
 
#footer {
  .rounded_corners;
}

Nested Rules

Rather than constructing long selector names to specify inheritance, in Less you can simply nest selectors inside other selectors. This makes inheritance clear and style sheets shorter.

#header {
  color: red;
  a {
       font-weight: bold;
       text-decoration: none;
    }
}

Resources:

http://www.dotlesscss.com/

http://lesscss.org/index.html

http://haacked.com/archive/2009/12/02/t4-template-for-less-css.aspx


   Nov 24

ASP.NET: Error: System.Security.Cryptography.CryptographicException: Keyset does not exist or Access is denied.

This article provides a possible solution to fix the following exception: System.Security.Cryptography.CryptographicException – Keyset does not exist or Access is denied.

I experienced this when I’m working with the Windows Identity Foundation.  I am doing a research for single sign-on, federated identification that will be implemented on BlastSuites project QuickSaas.

Message: Keyset does not exist

StackTrace:

at System.Security.Cryptography.CryptographicException.ThrowCryptogaphicException(Int32 hr)
at System.Security.Cryptography.SafeProvHandle._FreeCSP(IntPtr pProvCtx)
at System.Security.Cryptography.SafeProvHandle.ReleaseHandle()
at System.Runtime.InteropServices.SafeHandle.InternalFinalize()
at System.Runtime.InteropServices.SafeHandle.Dispose(Boolean disposing)
at System.Runtime.InteropServices.SafeHandle.Finalize()

Message: Access is denied.

StackTrace:

at System.Security.Cryptography.CryptographicException.ThrowCryptogaphicException(Int32 hr)
at System.Security.Cryptography.Utils._CreateCSP(CspParameters param, Boolean randomKeyContainer, SafeProvHandle&amp; hProv)
at System.Security.Cryptography.Utils.CreateProvHandle(CspParameters parameters, Boolean randomKeyContainer)
at System.Security.Cryptography.RSACryptoServiceProvider.ImportParameters(RSAParameters parameters)
at System.Security.Cryptography.RSA.FromXmlString(String xmlString)

Solution:

The application might be trying to write to the following folder path: C:\Documents and Settings\All Users\Application Data\Microsoft\Crypto\RSA\MachineKeys

If your application is using impersonation or using the IUSR_MACHINENAME or NETWORK SERVICE user, then configure the MachineKeys folder sercurities and give the user Read & Execute, List Folder Contents, Read, Write. If that doesn’t work, try giving the Everyone user the same permissions


   Nov 23

Using command line to run Fitnesse Test

Here are the steps in running the Fitnesse Tests from the command line

 

  1. Make sure you have Fitnesse and its running

     

 

 

  1. Use this command line
    1. Basic running of Fitnesse test using command line

       

      java -cp fitnesse.jar fitnesse.runner.TestRunner localhost
      8091
      BlastSuitesOsam
      –v

       

      localhost – the running fitnesse server

      8091 – the port number of fitnesse server

      BlastSuitesOsam – the test page or test suite you want to run

      -v – if you want to output the results in command window

       

      Here is the output of that command


     

    1. Running specific Fitnesse test page from command line

       

      java -cp fitnesse.jar fitnesse.runner.TestRunner localhost 8091 BlastSuitesOsam.ManageAccounts –v

      BlastSuitesOsam.ManageAccounts – the specific page to be run

       

      Here is the output of that command


     

    1. Running Fitnesse Test with XML file output – It will output the test results in xml and command window to be consumed by other application (emailing this file is one common scenario)

       

      java -cp fitnesse.jar fitnesse.runner.TestRunner localhost 8091 BlastSuitesOsam.ManageAccounts –v –xml C:\BlastSuitesOsam.xml

       

      –xml C:\BlastSuitesOsam.xml – any directory that has read-write permission

       

      Here is the output of that command



     

     

    1. Running Fitnesse Test on accessible network other than the localhost – running fitnesse test on Test servers on build servers are the common scenario for this

       

      java -cp fitnesse.jar fitnesse.runner.TestRunner bai-tmg 8080 BlastSuitesOsam.AccountCreation –v –xml C:\BlastSuitesOsam.xml

       

      bai-tmg 8080 BlastSuitesOsam.AccountCreation
      the Fitnesse server host, port and Fitnesse page you want to run

       

      Here is the output of that command



     

Conclusion

With this command line utility you can easily integrate the Fitnesse Test with your Continuous Integration Practices using Nant or other tool that able to used commands. You can run the test even if the Fitnesse Server is on other machine/server, like your build server, test server, development server, etc. And finally, the command line can output XML that contains the test results, very helpful if you want to consume this information such as emailing this results, creating new scrum work item for failed test, etc. Imagination is your limit.

Note:
1. In command line make sure you follow the proper casing of the highlighted text below as Fitnesse is governed by camel casing
java -cp fitnesse.jar fitnesse.runner.TestRunner localhost 80 FitNesse.SuiteAcceptanceTests

2. Running the commands number 2.c or 2.d multiple times will just overwrite the output file (C:\BlastSuitesOsam.xml)

Here is some useful resource