Methods to verify, are DataTables or DataSets the same.


I wanted to verify, are DataTables in DataSets the same. I found a few similar implementations on StackOverflow, but the one that I’ve selected 

( didn’t work and returned unexpectedly false, when comparing two cells with the same values

          tbl1.Rows[i][c]     2     object {long}
          tbl2.Rows[i][c]     2     object {long}
          tbl1.Rows[i][c] == tbl2.Rows[i][c]     false     
I found, that it should be used Equals instead of ==.
          Equals(tbl1.Rows[i][c], tbl2.Rows[i][c])     true
There are a few articles, explaining the difference and reasons behind it.
‘==’ Operators are overloaded, not overridden, which means that unless the compiler knows to call the more specific version, it’ll just call the object version

Below are tested methods to  check, are  DataTables or DataSets the same
/// <summary>
        /// </summary>
        /// <param name=”tbl1″></param>
        /// <param name=”tbl2″></param>
        /// <returns></returns>
         public static bool AreTablesTheSame( DataTable tbl1, DataTable tbl2)
            if (tbl1.Rows.Count != tbl2.Rows.Count || tbl1.Columns.Count != tbl2.Columns.Count)
                return false;

            for ( int i = 0; i < tbl1.Rows.Count; i++)
                for ( int c = 0; c < tbl1.Columns.Count; c++)
                   if (!Equals(tbl1.Rows[i][c] ,tbl2.Rows[i][c]))
                        return false;
            return true;
       /// <summary>
        /// Compare content of all rows in the table.
        /// </summary>
        /// <param name=”ds1″> The DS1.</param>
        /// <param name=”ds2″> The DS2.</param>
        /// <returns></returns>
        public static bool  AreTablesTheSame( DataSet ds1, DataSet ds2)
            if (ds1 == null && ds2 == null)
                return true;
            if (ds1 == null || ds2 == null) //only one is null
                return false;
            if (ds1.Tables.Count != ds2.Tables.Count)
                return false;

            for ( int i = 0; i < ds1.Tables.Count; i++)
                if (! DataTableHelper.AreTablesTheSame(ds1.Tables[i] ,ds2.Tables[i]))
                    return false;
            return true;

2 options to write tests for WCF Services

When writing Integration Tests for  WCF Services, you have 2 options to access SUT(system under test)
1. Inproc – Test Classes are calling methods from application DLLs directly.
2. External – Tests are calling external services using client proxy with specified URL.

If you own the code of the service, the Inproc method is preferred as it is allow to test units rather  the whole object as black-box.

If your tests are external clients of the service determined by URL, you need to have the service installed somewhere, e.g. on the test server.
So you need to use your services URL to run your external tests.

I’ve asked our team in a future when creating new/modifying existing test methods to use inproc approach rather than external clients.

Angular JS vs Knockout JS -quotes and links

Our team need to choose a JS framework. Base on the research Angular is the preferred framework. The only essential concern – if you need to support old IE6/7 browsers(but also there are articles how to support/workaround the IE issues)

Knockout supports almost all major browsers:
IE6+, Firefox 2.0+, Chrome, Safari and Opera 10+.
Link – Knockout : Browser support

Angular Supports only A grade browsers at the moment:
IE8 and higher,chorme, safari, FireFox,iOS, Android
Support for ie6/7 is possible in theory, but in practice we don’t run any ouf our regression tests on it, so it probably does not work

Link – Browser Support for Angular – Google Groups

  1. They are also similar in many important things: data-binding and directives. However, Angular does it better and prettier. You can stick your expression practically anywhere in the document using the {{}} clause and this alone give you quite a lot of power and yet readability. You also don’t need to useobservable for model objects – you use normal objects and Angular does its magic.
  2. Angular is more feature complete. It gives you out of the box a complete solution for almost anything you want in client-side web-app development, including mini-jquery, dependency-injection, redirection and deep-linking, animation and powerful, modern event handling. Knockout doesn’t provide any of this. 
  3. Angular’s html templating/customization/
    binding is less limited than KO – it let you build directives which are html tags, attribute, classes or comments. In KO, you can do it to comments (which looks rather ugly) or in the data-binding attribute. Much less expressive and pretty.
  4. Performance: sometimes performance is better in KO, sometimes in Angular (see the other answers for that). But i don’t see it as an issue anyways.
  5. Angular is built from testability and clean project organization better than any framework i know of (but i don’t know all of them).

I found Knockout easier to comprehend and get going with compared to Angular which is always a winner when starting something new but Knockout is pretty much just about binding so for things like routing and separation of concerns you need to use other libraries whereas Angular has all that built in. I think for smaller projects without too much logic required Knockout is ideal and I really like the simplicity of SammyJS however, for larger applications that requires dependency injection, a clear separation of concerns and the easy ability to unit test logic Angular is a winner. In this case the term “pick the right tool for the job” certainly applies.


Angular.js is a very nice framework . Developed by Googler’s, it has some very interesting design choices.

Pros: Very well thought out with respect to template scoping and controller design. Has a dependency injection system (I am a big fan of IOC). Supports a rich UI-Binding syntax to make things like filtering and transforming values a breeze.

Cons: Codebase appears to be fairly sprawling and not very modular. Views are not modular enough .


Knockout.js is an MVVM framework that receives lots of praise from its supporters. It stresses declarative UI bindings and automatic UI refresh.

Pros: Binding support. Great documentation and amazing tutorial system.

Cons: Awkward binding syntax and lacks a solid view component hierarchy. I want to be able to reuse components easily. I also feel like identifying as an MVVM framework is deleterious. Hardly any of these frameworks are MVC, but are of the MV* variety (MVP, MVVM, etc)

Additional reasons from my co-worker Krishna Nadiminti 

Which framework to use?

A comparison of Angular Vs. Knockout: –

A sample app some guys did in various frameworks:

·         TODO App in Knockout [Not bad – but still one file with too many things in it]

·         TODO App in Angular [More files, forces you into thinking about structure and avoiding jQuery]

·         TODO Apps in other frameworks (for reference only – I don’t think we can spend days evaluating the best framework – and frankly it does not matter that much.)


About that steep learning curve:

I’ve worked with both – it took me almost the same time to get a brand new app running  in KO vs Angular. Once I looked at Angular – I remembered all the additional frameworks (require, sammy, amplify,   I needed to learn to make a ‘properly designed’ client-side app with KO as the basis.


Other things we considered in choosing AngularJS:

Momentum behind the framework (Google!)

Completeness in terms of client-side application requirements (clean design, testability, data-binding, routing, module loading, ui-widgets)

Browser support

Plugging into existing apps

Playing well with other frameworks/scripts


More links:

Some pro’s of AngularJS over KnockoutJS

Angular JS and old versions of IE 

POSTSHARP error PS0052: The plug-in “PostSharp.Patterns.Diagnostics.Weaver” was not found

After some merge of source code branches I’ve got a build error
 POSTSHARP : error PS0052: The plug-in “PostSharp.Patterns.Diagnostics.Weaver” required by the type “PostSharp.Patterns.Diagnostics.ILogAspect” was not found. 
I wasn’t able to find immediately which code caused the error, and google also didn’t give me an answer.
After some investigation I found that PSproj file had missing entries for PostSharp.Toolkit.Diagnostics.Weaver.dll and PostSharp.Toolkit.Diagnostics.Weaver.NLog.dll.

It will be easier if error PS0052 will include name and line from PSproj file

<Project xmlns= xmlns:dg=clr-namespace:PostSharp.Patterns.Diagnostics;assembly:PostSharp.Patterns.Diagnostics ReferenceDirectory={$ReferenceDirectory} >
  <Property Name=LoggingBackEnd Value= nlog  />
  <Using File=default />
  <!– if the following 2  entries will be missing, it would cause PS0052 error –>
<Using File=”……packagesPostSharp.Toolkit.Diagnostics.NLog.” />
  <Using File=”……..packagesPostSharp.Toolkit.Diagnostics.” /> 
    < dg:LoggingProfile Name = Exceptions OnExceptionOptions=IncludeParameterType | IncludeParameterName | IncludeParameterValue | IncludeThisArgument OnEntryLevel=None OnSuccessLevel = None />

    <!– Add exception logging to everything  .–>
    < LogExceptionAttribute xmlns=clr-namespace:PostSharp.Patterns.Diagnostics;assembly:PostSharp.Patterns.Diagnostics  AttributeTargetAssemblies=“MyProj.ServiceInterfaces AttributeTargetTypes=MyProj.ServiceInterfaces.* AttributeTargetMembers= * />

Misleading compiler error “is a ‘type’ but is used like a ‘variable'”

The following C# line to call AutoFixture method
Caused Error     63     ‘System.Collections.Generic.List<System.Collections.Generic.List<BusinessEntities.FlightItem>>’ is a ‘type’ but is used like a ‘variable’     
It wasn’t obvious, that closing ‘>’ was missing.
 I believe  that compiler can recognize and provide better error message.

My favorite Visual Studio tools

Recently I’ve setup Visual Studio on new machine and I wanted to install a few tools, that I am using all the time.
It includes 
See also my old post Tools to debug/Trace ASP.NET applications.(many of them are outdated already)