A new practitioner of TDD and unit tests has much to learn: how to what are acceptance tests? how to write tests that won’t break on every trivial change? what mock objects and why should you care? How do I test my product code? So if you’re looking for a place to learn all those … Continue reading Three Day TDD .NET Course (Israel)
Tag: .NET
RTFM–the tale of ReaderWriterLockSlim
The .NET BCL (Base Class Library) is readable, easy to understand and not less important documented. This is a story on where a simple reading of documentation could have saved us from a minor bug… If you’ve been using .NET you might be familiar with the ReaderWriterLock essentially a lock that enable multiple readers or … Continue reading RTFM–the tale of ReaderWriterLockSlim
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
Spot the bug – misbehaving server
We had a strange issue at work – we had a misbehaving server, who worked perfectly well with one client but had strange issues when several clients connected to it. The server would broadcast a message to all of its clients but only one client would receive that specific message, re-sending the message would fix … Continue reading Spot the bug – misbehaving server
Multiple asserts – done right
If you’ve been writing unit tests for some time or seen a good presentation on how to write unit tests you probably heard the “One assert per test” rule. There are real benefits in having only one assert in each tests – you get a focused tests, it’s easier to understand what caused the test … Continue reading Multiple asserts – done right
How to ignore thrown exceptions
Yesterday I came across this question on StackOverflow:Is there a better way to ignore an exception in C# than putting it up in a try catch block and doing nothing in catch? I find this syntax to be cumbersome. For a code block, can't I simply "tag" it in such a way so as runtime … Continue reading How to ignore thrown exceptions
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