Geeks With Blogs

The Life and Times of a Dev Yes, we're really that weird Unit Testing
Virtual Com ports
In the hardware world, much of the communication still happens over RS232 or RS485 serial ports. Unit testing this can be a challenge. To help with that, I’ve created a custom SerialPort wrapper, which, among other things, helps with multiple threads trying to hit the serial port at the same time. When you’re iterating over actors, this is a key bit of functionality that needs to happen. Because I have this class injected, I can easily substitute a mock to the things that actually do serial communication. ......

Posted On Thursday, December 11, 2014 5:36 PM

Unit Testing Multi-threaded code
I spent the day today writing unit tests for code I wrote yesterday. No, I’m not a big fan of TDD. I am, however, a big fan of high (as close to 100% as practical) code coverage. The device I’m working on is very multi-threaded. As a matter of fact, a key principle is DON’T BLOCK! Because of this, there are quite a few Task’s, lots of awaiting, and several timers that poll on a regular basis. This makes for code that can be tricky to unit test. After all, if you’re not blocking, you’re on a different ......

Posted On Thursday, November 27, 2014 12:29 AM

Testing EntityFramework with Moq
Let’s face it, EntityFramework is a pain to mock. With few interfaces, testing things that use it can be a real pain. Here’s a few things I’ve found to make it easier: Make sure that you have an interface for your DbContext object so that it can easily be mocked. If you’re doing Database First, be aware that EF 7 will eliminate EDMX support, so welcome to the code first era (I hear you . . .). Rather than using your Dependency Injector to directly inject an instance of your IDbContext, create a context ......

Posted On Thursday, November 20, 2014 4:06 PM

Copyright © Robert May | Powered by: GeeksWithBlogs.net