Close

Small unit testing tip

When asserting the content of collections, lists, dictionaries,… in unit tests, don’t do this: Assert.That(this.result.Contains(this.expectedResult1)); Assert.That(this.result.Contains(this.expectedResult2));   Or this: Assert.AreEqual(this.expectedResult1, this.result[0]); Assert.AreEqual(this.expectedResult2, this.result[1]); What if you implemented your method wrong, and the result contains more than two elements? Unless you’re totally not interested in the size of the result, always check if the collection is […]

Read More

Speed up development with snippets

Do you find yourself often writing the same pieces of code? I guess we all do: the INotifyPropertyChanged interface and the PropertyChanged method in WPF projects are one example. Unit tests more often than not have the same structure (at least on a per-project basis). Visual Studio’s snippets functionality can speed up your work in […]

Read More

How to use NHibernate’s SQLCriterion – take 2

After having an interesting discussion with Stefaan (colleague, friend, ex-colleague and now colleague again) about my previous post on NHibernate’s SQLCriterion, I decided to have another look at my usage of SQLCriterion. He argued that with SQLCriterion, you’re more or less working around the ORM, which I can agree with. After putting it on StackOverflow, […]

Read More

How to use NHibernate’s SQLCriterion

I recently needed to use NHibernate’s SQLCriterion, but lost some time on finding out how to use it. Once you’ve found it, it’s quite simple actually: ISessionFactory sessionFactory = GetSessionFactory(); ISession session = sessionFactory.GetCurrentSession(); ICriteria criteria = session.CreateCriteria(); var sqlString = new SqlString(“{alias}.GroupId = ” + groupId); criteria.Add(new SQLCriterion(sqlString, new object[0], new IType[0])); return criteria.List(); […]

Read More

Trunk based development

Update: This is an old article that helped us at the time, using a centralized version control system (Subversion). We created our own branching strategy, which I would heavily advise against these days. The issue with making up your own branching strategy is that, like most not-invented-here solutions, you’re probably not going to be smarter […]

Read More

Coding pet peeves

This was a blog post I had lying around, waiting to be posted. This post on code smells on the All Your Base Are Belong To Us blog reminded me of it. So here goes. Everyone has coding pet peeves. Pieces of code they can’t resist the urge to change when they see it. Of […]

Read More

Exceptions everywhere

On two projects I have worked on, I’ve seen a lot of this: public void DoSomething() { try { // actually do something here } catch (Exception ex) { throw new Exception(“Unable to do something”, ex); } } I’ve seen this in various differing styles: not including the original exception in the newly thrown one […]

Read More

Testing your code

Thinking about it, the team I work in has quite a lot of ‘security checkpoints’ for our code. We try to put as many pieces of code under unit test. However, we are often hindered by an old framework that can be described as a sort of ‘CSLA meets Active Record’. If unittests are impossible, […]

Read More