Skip to main content

3 posts tagged with "c#"

View All Tags

Fun with (Enum) Flags

· 3 min read
Kyle Oettle
Software Engineer

Hi Everyone 👋

One of the lesser known but my favorite features of Enums are Flags

Enums are usually used to indicate a single option, like a day of the week, your favorite colour, pizza size... We all get it, we've all used it, but how often have you seen an array of Enums being passed around in your code?
There was probably a good reason for it if you have. Maybe an array of features, an array of preferred contact methods, supported payment methods? This is what's really cool about Flags, You can capture a selection of enums in a single value :satisfied:

Async (a)void

· 6 min read
Kyle Oettle
Software Engineer

Hi Everyone 👋

A while ago we had the unfortunate event of breaking prod 😮
We made some small changes to our .net api, all tests passed, everything was good and the world slept peacefully that night, until we saw the service started going down seemingly at random! Turns out it wasn't random at all, it was a pesky async void which we missed changing to an async Task and it caused the entire service to come crumbling down.

Most of us know that when you want to change a method from sync to async, you change the calls to an async Task, it's pretty simple and straight forward, but we forgot to change one of the signatures from void DoSomething() to async Task DoSomething() and left it as async void DoSomething()

Unit Testing - Test Spy Pattern

· 5 min read
Kyle Oettle
Software Engineer

Hi Everyone 👋

90% of blogs I read start with something about unit testing, so to not dissapoint anyone I'm making my first blog post about unit testing 😄

I'm a fan of unit testing code for various reasons, mostly because I've felt the pain when there were none! So I want to chat about a pattern I've been using for the better part of a decade but only found out today that it's called the Test Spy Pattern.

The Test Spy is designed to act as an observation point by recording the method calls made to it by the SUT as it is exercised. During the result verification phase, the test compares the actual values passed to the Test Spy by the SUT with the values expected by the test.

Okay I don't think my implemntation is exactly the classic Test Spy pattern, but close enough!