07 August 2013

Record Filtering in XamDataGrid

Sample code which enable record filtering in XamDataGrid;-
Reference dlls-
InfragisticsWPF4.DataPresenter.v12.1
InfragisticsWPF4.v12.1

   1:  <Window x:Class="XamDataGridSamples.Window1"
   2:          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
   3:          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
   4:          xmlns:igDP="http://infragistics.com/DataPresenter"
   5:          Title="Window1" Height="300" Width="300">
   6:      <Grid>
   7:          <igDP:XamDataGrid Name="xamDataGrid1" BindToSampleData="True">
   8:              <igDP:XamDataGrid.FieldSettings>
   9:                  <igDP:FieldSettings
  10:                      AllowRecordFiltering="true" 
  11:                      FilterLabelIconDropDownType="MultiSelectExcelStyle"/>
  12:              </igDP:XamDataGrid.FieldSettings>
  13:              <igDP:XamDataGrid.FieldLayoutSettings>
  14:                  <igDP:FieldLayoutSettings
  15:                      FilterUIType="LabelIcons"
  16:                      FilterRecordLocation="OnTopFixed" />
  17:              </igDP:XamDataGrid.FieldLayoutSettings>
  18:          </igDP:XamDataGrid>
  19:      </Grid>
  20:  </Window>
Screenshot:

04 August 2013

HTML5 Introduction

Recently I got some time to take a dive in to HTML5 and I would like to share my experience here.  This was long pending as, the news of HTML5 was getting demands a while when companies like Apple started using this. Every new Apple mobile device and every new Mac supports HTML5 with Safari web browser. All major browsers (Safari, Chrome, Firefox, Opera, and Internet Explorer) continue to add new HTML5 features to their latest versions.
HTML5 is not one big thing; it is a collection of individual features like support for individual features like canvas, video etc. This will be my Introduction web log on HTML5 and I will try to go through most of them in my subsequent blogs. Like most of the cases my learning process starts with open questions and then tries to reach to answers.
What is HTML5?
HTML5 is a markup language for structuring and presenting content over web pages. HTML5 is the next revision of the Hypertext Markup Language (HTML). In theory, HTML5 will allow the Web browser to become a development platform. A primary goal for this is to ensure interoperability among browsers so that Web applications and documents behave the same way no matter across the devices. (Older browsers that do not support HTML 5 will be able to ignore the new constructs and still produce legible Web pages. That’s sounds cool right ?)
Why HTML5?
After the birth of original HTML it has gone through many years of updates. And all these updates they tried to integrate with different versions. HTML 5 is the most recent one among that. For example when video streaming came on web there was no in built support for this. So companies like Quick Time, Real Player, Windows Media player and flash introduced there on and in order to use this user has to download external plug-in.  The idea behind HTML5 is to come up with a consistent experience across all devices and browsers. Today, the different browser's are working together to achieve this goal.
New Features
Some of the most interesting new features in HTML5:
  • The canvas element for 2D drawing
  • The video and audio elements for media playback
  • Support for local storage
  • New form controls, like calendar, date, time, email, url, search
Here we will try to experiment with few among the above. Let’s take a small sample of Playing a YouTube Video in HTML. You can achieve this few lines-of code.

<!DOCTYPE html>
<html>
<body>
 
<iframe width="420" height="345"
src="https://www.youtube.com/watch?v=SE_X9cF431g">
</iframe>
 
</body>
</html>
Also please find samples of script and noscript tag. 

<!DOCTYPE html>
<html>
<script>
document.write("Hello World!")
</script>
<noscript>Sorry, your browser does not support JavaScript!</noscript>
</body>
</html>
We will continue exploring the other features in next logs.

03 August 2013

Rhino Mocks

Unit testing is all about testing the functionalities of the class under test and not its dependencies. It is some time difficult to unit test dependency classes. For example database components, web services, event channels or a component which involves any type of server etc. For these scenarios instead of using the real instances of these dependencies it would very nice to replace them with mock objects. All my previous projects I prefer to use interfaces and create mock objects for them. It is very easy to understand and implement. . Its purpose is to ease testing by allowing the developer to create mock implementations of custom objects and verify the interactions using unit testing. Rhino mocks have high importance in TDD development world.
Well, this is not something new that we are trying to re invent but, trying to share my experience of using Rhino Mocks in .net application and providing solution to resolve build error after including rhino mocks dll reference to your project.
Sample:
It is Simple to use Rhino Mocks first you need to download Rhino Mocks then unzip it somewhere on your hard drive.  Then in your projects just go to add references in the solution explorer then the browse tab then find the assembly where you unzipped it and there you go.

This is a simple application which tells us how to consume rhino mocks and write a sample unit test. To keep it simple I have used primitive data types as return type from mock service.

Firstly, don't forget to add references to NUnit and your Rhino Mocks assemblies.
Code:

   1:  using Rhino.Mocks;
   2:  using NUnit.Framework;
   3:  interface IEmailServer
   4:  {
   5:      bool TrigerEmail();
   6:  }
   7:  public class EmailServerAbstractlayer : IEmailServer
   8:  {
   9:      public bool TrigerEmail()
  10:      {
  11:          return true;
  12:       }
  13:      }
  14:  [TestFixture]
  15:  public class EmailServerClient
  16:  {
  17:  [Test]
  18:  public void SaveClientInformationTestWithMock()
  19:  {
  20:      // logic to add Save Client Information
  21:      //Logic to test Trigger Email after saving the data.
  22:      var expected = true;
  23:      IEmailServer emailServer = new EmailServerAbstractlayer();
  24:      Assert.AreEqual(true, emailServer.TrigerEmail().Equals(expected));
  25:  }
  26:  }

Problem:

When You compile this code you will get below exception:-

“The type or namespace name 'Rhino' could not be found (are you missing a using directive or an assembly reference?)”
Solution:
If you are getting this exception please do below steps:
1)     Check your project properties –> Application -> Target framework.  If it’s set to a “Client Profile” (.NET Framework 3.5 Client Profile or .NET Framework 4 Client Profile), Rhino won’t work.  The proxy system built into Rhino needs the full .NET Framework. Change the Target Framework to a “Full” framework, either the .NET Framework 3.5 or the .NET Framework 4 selections, and Rhino will be happy again.
2)     Add the reference to the third-party DLL (Rhino.Mocks.dll) into the project and ignore the warning by clicking "Yes".
3)     Click on the project reference and in the property window modify the "Specific Version" of Rhino.Mocks to "True".
4)     Right click on the project node and select "Edit Your Project Name Here".
After the line starting with
 
<Reference Include="Rhino.Mocks, ...">, add the following line: <SpecificVersion>True</SpecificVersion>
5)  Reload and rebuild the project.

(Using VS 2010)