Tuesday, September 18, 2012

.NET Testing Frameworks

Most of my testing experience has been with MSTest, NUnit and Selenium and I feel this is an area I need to explore in more depth, so I thought I'd put the question to my colleagues and readers: What testing frameworks do you prefer and why? Below are a few lists of some .NET oriented frameworks with some notes on what sets each of them apart from others. I welcome comments confirming, challenging or correcting these notes as well as suggestions of others I may have missed.

Unit Testing
  • MSUnit - Included with VS, Easy to implement
  • NUnit - Most common third party framework
  • xUnit - Extensible, lends itself to TDD/BDD
  • MbUnit - RowTest for parameterized testing

Acceptance Testing (web)
  • Selenium - Relies on CSS ID and class selectors
  • WatiN - Works best with IE

Tools

Mocking

Monday, September 17, 2012

NE Arkansas .NET User Group

I'm scheduled to speak at the Northeast Arkansas .NET User Group on September 27, 2012. The topic of this talk will be Testing the Untestable with Microsoft Visual Studio 2012 Fakes. I've given this same talk several times at regional conferences and user groups and an overview can be found on my blog, however one great thing about speaking at local groups like this is that the audience helps direct the session and we often end up focusing on areas that are most useful to that particular group.

While anyone is welcome to show up, the group leader has requested that attendees RSVP so they have an idea of how many to expect. See you there!

UPDATE:
If you attended this talk and would like to provide feedback, you can do so at SpeakerRate.com.

Tuesday, September 11, 2012

Great MVVM, WPF, SOA and EF4 Articles

I was asked to put together some links to articles that would help our IT department ramp up on some of the patterns and technologies we're using. By the time I was done with the email, I realized it might be of use to others outside our organization so part three of my MVVM with WPF series was born. There are many approaches and I highly recommend researching beyond this handful of articles, but for anyone not yet familiar with these concepts I hope they help.



The Model-View-ViewModel (MVVM) pattern helps to cleanly separate the business and presentation logic of an application from its user interface (UI). This separation is key for testability, maintenance and scalability.

Here’s an introduction to MVVM which illustrates how it leverages WPF data binding and commands.

The main difference between what we’re proposing and how they define MVVM in the previous articles is, by using a convention-based framework such as Caliburn.Micro and events/commands to wire up the View and ViewModel, they are completely decoupled allowing for better testability and future scalability. The Caliburn.Micro wiki has a good introduction to the functionality it provides.

This article gives a good introduction to Attribute Based Validation which allows us to keep validation logic down in the business layer and entities where it can then bubble up and be reflected in the UI.

If there’s interest in going deeper, here’s an article on using a Service Oriented Architecture (SOA) to decouple service providers from consumers allowing for greater reuse and insulating the application from core business logic.

Finally, a  series of articles outlining the use of a Generic Repository with Entity Framework 4 (EF4) to reduce the amount of plumbing that must be written and maintained for data access.



See also:
MVVM with WPF Series Part 1. Disconnected WPF Applications
MVVM with WPF Series Part 2. WPF MVVM with WinForms Controls

Friday, August 17, 2012

How much is experience worth?


During the Facebook IPO in May, UBS lost more than $350 million as a results of a glitch in their systems that re-sent buy orders and accumulated 40 million shares that would have to be sold at a loss.

As a software developer, it's not difficult to imagine the type of glitch that might cause such an issue. Something as small as comparing a value to null or improper error handling can cost a company hundreds of millions of dollars, which begs the question, how important are the architects and developers creating these systems?

It's easy to understand the importance of experience when building something as physically monumental as a sky scraper. People's lives depend on the quality of design and workmanship. Unfortunately, many companies don't see their enterprise software in the same light. They balk over the cost of senior talent and begrudge resources for quality control, then end up spending much more in damage control when systems fail.

How can we nurture a corporate culture that recognizes the value of experienced talent and proactive quality control?

Friday, August 10, 2012

You're Interviewing Them

Most of us are raised to believe that a job interview is where a potential employer asks you a bunch of questions to see if you're right for the job, but did you know that the best candidates often spend as much time asking questions as answering them?

Asking questions shows that you're serious about the job and indicates potential employment is as much your decision as it is theirs. Questions about culture and coworkers are a great way to take the focus off money and help the interviewer realize you're looking ahead to what employment with them might look like. A potential long-term employee wants to know if it will be a good fit and somewhere they will be happy working for an extended period of time.

Once an interviewer has established that you have the skills to do a job, the next question on their mind is usually performance. It's one thing to have ability, but quite another to have work ethic and focus. By asking about their top performers you can show your interest in becoming one of them. By keeping the question open ended, such as "What is the most important quality you see in your top employees?", you can gain insight into what's most important to them and provide examples of how you've displayed said quality later in the interview.

Asking the right question isn't just about gathering information and doesn't replace the need for preparatory research. In fact, it's vital to have a basic understanding of the company's business in order to know what questions to ask. One example is the question, "How do you deal with [insert challenge here]?" Addressing a challenge facing the business not only shows you've done your homework, but it also indicates you're a problem solver and interested in being part of the solution.

Some questions depend on the interviewer. When being interviewed by someone from human resources it is probably best to keep questions general with focus on the overall company and position in question. With a hiring manager you're able to delve deeper into how they measure success and what they need most in an employee. The best opportunity for information gathering, however, comes when interviewing with a peer. Asking about their experiences with that company and manager not only provides valuable insight into the position, but shows respect for their opinion which can be very endearing.

Good questions don't take the place of being qualified and informed, but they are a great way to make yourself stand out from the crowd and determine if this specific opportunity is right for you.

Thursday, August 9, 2012

WPF MVVM with WinForms Controls

This is the second part of my series on using MVVM with WPF. In the first article I discussed architecting disconnected applications and how MVVM was a great fit for WPF smart clients as well as Silverlight web clients. Now we move on to the process of refactoring an old Windows Forms application to use this new architecture.

The main concern with changing an underlying technology is the initial investment in rewriting code. To help mitigate this issue, WPF has provided a WindowsFormsHost element that allows us to host WinForms controls inside of a WPF Page. Obviously this limits how effectively we can leverage other features provided by WPF, however with a few workarounds it's a viable solution to avoid having to completely rewrite those old WinForms controls.

How easy is it to implement the WindowsFormsHost?
<WindowsFormsHost><wfh:WinFormsUserControl x:Name="LegacyUserControl" /></WindowsFormsHost>

Okay, it's only slightly more complicated than that. You will need to add add a reference to WindowsFormIntegration and possibly System.Windows.Forms (if it is not already referenced).

Now the question comes to how we interact with this control from our ViewModel since we can't use WPF bindings in our WinForms control. We can bridge this gap by adding events to our WinForms user control.


Then we wire up the events to our DataContext in our WPF Page code-behind.


While I generally prefer to avoid using the code-behind, we also don't want our ViewModel to be aware of the internal workings of our View.

The end result is our Windows Forms control interacts with elements in our WPF Page.

demonstration

Download Demo Source Code