Using null-coalescing to find item in multiple collections

A co-worker showed me this:var result = collection1.GetObjectByAtSpecialLocation(location) ?? collection1.GetObjectByAtLocation(parent, location) ?? collection2.GetObjectByAtSpecialLocation(location) ?? collection2.GetObjectByAtLocation(parent, location);I’m still trying to decide whether it’s a good practice and if it’s readable or not…In case you’re not familiar with ?? operator a.k.a null-coalescing operator it’s basically returns a default value if the left side is null so the … Continue reading Using null-coalescing to find item in multiple collections

Find out where is the method that was called unexpectedly using fake objects

Every Isolation/Mocking framework out there can verify that a method of a fake object was called and not less important make sure that certain methods are not called. Let’s say that I want to make sure that a method didn’t encounter any errors during execution but verifying that logger.Error was not called: [TestFixture]public class MyClassTests{ … Continue reading Find out where is the method that was called unexpectedly using fake objects

How to: Invoke events inside your production code using Typemock Isolator

 Using Isolate.Invoke.Event enable event driven unit testing by invoking events on fake or “real” object. If you use events to communicate between parts of your application – it’s a feature you need to know and use. In the last couple of months I have been using it a lot but there is one wall I … Continue reading How to: Invoke events inside your production code using Typemock Isolator

Rapid Dev – a new unit testing tool is born

It’s no secret that the .NET community has a lot to learn as far as unit testing is concerned. One of the contributing factors to unit testing adaptation is tool support – it’s not secret that if developers can crate and run tests easily form the comfort of their development environment (i.e. Visual Studio). But … Continue reading Rapid Dev – a new unit testing tool is born

Discovering race conditions using PostSharp

Since the beginning of computer programming one of the problem that always baffled software developers was how to make sure that their code would run properly once threading has been introduce to the application. I’ve been experimenting with PostSharp for a couple of weeks and I thought that perhaps I can use it to discover … Continue reading Discovering race conditions using PostSharp