March 25, 2015

Async/Await and Recursion

While using the new async/await keywords in C# 5.0 for the first time, I noticed an interesting aspect to how recursive methods behave when using await. For one method I was working on, Resharper notified me of a possible stack overflow exception with a “function is recursive on all paths” warning, but it didn’t fail at runtime. Instead, it continued happily calling itself with no issues. What keeps it from failing is the use of the await keyword when calling DoWorkAsync(). Read more

December 29, 2014

Code This, Not That - SpecFlow Edition

In 2007 a different kind of diet book was published that took a concise approach to making the right food choices. Readers of the book were presented with good and bad selections at popular restaurants and told why the good options were better than the others. Eat This, Not That! made changing your diet simple and realistic. No gimmicks like the Atkins diet or the current trend of cleansing. Just real options available in many restaurants. Read more

December 3, 2014

Generate SQL Delete Statements That Respect FK Relationships

Have you ever needed to delete a record from a database table only to be thwarted by one or more foreign key violations? Then when you try to delete records from the child tables you find a deep hierarchal relationship bound together by yet more foreign keys? I recently ran into this issue with a SQL Server database. I needed to trim data from several large tables that had deep and wide relationship hierarchies enforced by foreign keys. Read more

October 18, 2014

Useful Regex for SpecFlow Bindings

Below is a list of useful regular expressions (regex) for annotating SpecFlow bindings. I’m treating this post as a reference and will be updating it with new items from time to time. Singular or Plural Support singular or plural wording. Filter for Enum Values If your binding takes an enumeration for an argument, you can limit the inputs from the Gherkin to just the valid values. In the snippets below, the possible values for the SortOrder argument are limited by the regex (ascending|descending) thus avoiding any runtime exeptions due to a bad value. Read more

October 10, 2014

Overusing Generics in .NET

Generic types were a great addition to C# 2.0, but they are occasionally overused. There are times where calling object.GetType() or passing the type as an argument are sufficient. A good example can be found in the Specflow source code. The TechTalk.SpecFlow.Assist.InstanceComparisonExtensionMethods class contains a useful extension method CompareToInstance<T>() which takes a table of expected property values and compares them against an object. The generic type is completely unnecessary in this case. Read more

September 30, 2014

Strategies for Managing State in SpecFlow

SpecFlow is an extension for Visual Studio that binds software specifications written in the Gherkin language to executable code written in C#, VB, or some other .NET language. One of the challenges of implementing a SpecFlow scenario is how to manage test state in between steps. At first glance, state management seems like an easy problem to solve, but as your test suite grows, maintaining the implementation is as difficult as any large software project. Read more

© Joe Buschmann 2020