Mar 25, 2011

VS2010 Trick: Alignment of "=" symbol

If you need to align variables and equality symbols as follows:

var1     = 1;
varvar2  = 2;
varvarr2 = 3;

Just install VS2010 Power Tools.

Here is a short cut to use: CTRL + ]

Have a good day!

Dec 8, 2010

UI Spy Replacement: UI Verify

Here it is: http://uiautomationverify.codeplex.com/
So far, I like it very much!

Take care!

WPF: In the search of automation Id for Popup

In case you are doing WPF development, and for some reason you are using Popup control (primitive), and it has no AutomationId (no matter what!!!) here is a cure:
 - How to set AutomationID and Name for Popup

Happy coding!

Dec 5, 2010

10 Pancakes #3

Enjoy good links:
 - Best code comments on StackOverflow 
 - Programmers jargon (good guidelines) on StackOverflow
 - Ultimate dev cheet sheet collection and more
 - Book: Software for your head (free PDF)
 - Go distributed .net with DryadLINQ
 - Visual Studio CTP with async pattern (C#5?)
 - Package management for .net
 - Rx Guidelines
 - Skills Matter - Yes, they are! 

Thanks!

Nov 29, 2010

Unity Interception (AOP)

Recently, I have been working on adding Unity Interception and found out that it is extremely poorly documented. Here is the list of links one may find useful:
 - The bare bones of Unity interceptions
 - Order Property and Firing of Handlers
 - Unity interception performance
 - INotifyPropertyChanged With Unity Interception AOP
 - Implementing INotifyProperyChanged with Unity Interception

Also, there are always opened questions here: unity-interception

Sep 13, 2010

10 Pancakes #2

This is yet another links list, enjoy.


 - WPF Triggers, Actions, Behaviors
 - Firedrill best practices for money saving
 - Patterns for Parallel Programming for .NET 4.0 book / guidelines
 - Code Contracts
 - Rx Extensions
 - Rx for Javascript
 - Free agile trainings
 - In fact, I see none people who do "agile" and familiar with agile principles and manifesto at the same time. I wonder why...
 - And dynamic languages are driving me crazy these days, I should learn a couple:
   * http://blog.wekeroad.com/2010/08/09/csharps-new-clothes
   * http://blog.wekeroad.com/2007/08/29/the-c-makeover

Aug 25, 2010

Why I love RhinoMocks?

Well, to begin with I really do :)

Anyway, currently I am involved in several projects simultaneously. And it turned out that each project has it's own 3-rd party libraries and tools. Well, one has RhinoMocks and the other has Moq. I do not mind learning new things so I thought why not to try Moq.

Everything went well (without documentation reading) until I decided to create a mock of the сlass with "virtual" method. The test was simply to check whether the method gets called. I wrote the test and it failed. Well, I added good code - failed again. Went through the debug - failed anyway :) What could go wrong?

Here is my class I had to mock:
    public class MyViewModel : ViewModelBase    
    {
        public MyViewModel(IEventAggregator events)
        {
            this.eventAggregator = events;
            this.SubscribeToEvents();
        }

        // ... Lot's of other code.

        public virtual void VerifyCurrentView()
        {
            // Smart things here
        }
    }


The class subscribes to certain events from event aggregator and tries to call VerifyCurrentView method after events are handled.

So, how would you check whether the VerifyCurrentView method code actually gets called?
Never mind, here is how I thought I could do this:

    var vm = new Mock< MyViewModel >(events);

Guess what? The constructor never gets called in this case :( I spent an hour trying to figure this out - no luck.

Consequently, the following test (mock) does not work:

[Test]
    public void My_test_Moq_version()
    {
        var events = new EventAggregator();
        var vm = new Mock< MyViewModel >(events);


        vm.Setup(m => m.VerifyCurrentView());


        // Act
        events.GetEvent< AlertHistoryLoadedEvent >()
            .Publish(new HistoryTypeInfo[0]);


        vm.VerifyAll();
    }

And I had no idea why it was happening and neither a desire to know "the truth". I spent another 5 minutes to write the same with RhinoMocks:

[Test]
        public void My_test()
        {
            var events = new EventAggregator();
            var vm = MockRepository.GenerateMock(events);


            // Act
            events.GetEvent()
                  .Publish(new HistoryTypeInfo[0]);


            vm.AssertWasCalled(c => c.VerifyCurrentView());
        }

And it works! Just like that.
RhinoMocks just rocks!

10 Pancakes #1

It has been a while since my last post. I think I will be posing more in the future, we will see :)

Anyway, today I would like to start a new ideas that I tried to put off too long time for now. You see, I find too much of interesting stuff every day and I cannot simply throw it to everybody via IM and e-mails.

Starting this week I will be posting links I went through and think would be beneficial to my friends, colleagues and other good people.

So, here is the first 10 links:
 - Scrum check-list 2010 free e-book:
 - New Uncle Bob Martin blog - the clean coder
 - Scott Hanselman over Effectiveness and Efficiency
 - SICP Book
 - Pro HTML5 book excerpt - Chapter 6
 - New Embedded DB for .Net - EffiProz
 - Managed Esent DB for .Net
 - RavenDb
 - The blog of Managed Esent author

May 6, 2010

Power Tools for Visual Studio 2010

Microsoft has gathered all power tools together on one site. Great!
So, whenever you need one of those go there to get it:

  • http://msdn.microsoft.com/en-us/vstudio/bb980963.aspx


Have fun with it!

PS: Until Rob Conery will create a better tool just for you.