Mocking internal interfaces

Yesterday I’ve worked on connector library used to access data warehouses provided by two external vendors. In order for it to be easy to use I limited public members to:

  • library interface – can be used to aggregate connectors and testing
  • two connector classes that provide public methods to retrieve prepared responses
  • DTO request and response classes

Continue reading “Mocking internal interfaces”

Elipse and Circle inheritance problem

Recently I’ve been listening to Coding Blocks podcast, an episode which subject was software design anti-patterns. They described one of them, which is pretty well known: the Circle-Ellipse problem.

The problem goes like this: let’s assume we’re writing a program and we’ve created IShape interface (which might have methods to calculate circumstance and area of the shape). Now we create Ellipse, which implements IShape interface and follows that with Circle class. Now since Circle is a special case of Ellipse, and every circle is an Ellipse it naturally should inherit from Ellipse.

Continue reading “Elipse and Circle inheritance problem”

I just wrote that without StackOverflow

In the life of many developers comes the moment, when you write something non-trivial and it just works. And you don’t have to google anything! It’s quite thrilling!

I have been creating a mock object for testing, that could store several graphs at the same time. The graph was very simple, it could have only root (portfolio) and leaves of several types. Linking was done from leaf to root, by setting two properties (a little redundant): parentId and parentName.

Continue reading “I just wrote that without StackOverflow”

Coding Blocks – great recommendation for beginners

Last week, our colleague Douglas (who hopefully is quite successful in combating dehydration and other threats during his trip to south-east Asia) recommended to me a  programming podcast Coding Blocks. And since object-oriented design patterns were never my strongest side I’ve decided to take some time and try to give it a try. So I immediately downloaded around 30 episodes, which totally clogged my weekly podcast queue.

Continue reading “Coding Blocks – great recommendation for beginners”

Mock – my favourite mock engine

When I try to unit test class one of the most important things is to eliminate all dependencies and replace them with proper mocks. Such mocks allow me to fully control inputs that object will access and verify that proper methods have been called.

Recently I’ve written one business logic class that manages SPA (Single Page Application) and uses four different repositories from which it pulls data and presents them as Web API.

Continue reading “Mock – my favourite mock engine”

NCrunch – A plugin that makes TDD sexy

Before I started working at my current job I’ve never seen continuous testing tools. For me running unit test, despite being really useful, was a chore that I would do after modifying several files and (usually) writing few additional tests.

It shouldn’t come as a surprise, that several of them will be failing, enabling me to do what developers like the most – fixing errors in their code or, even more fun, fixing errors in somebody else’s code.

Continue reading “NCrunch – A plugin that makes TDD sexy”