iOS Unit Testing With OCMock
Mock objects are an important driver of test driven development (TDD). They give developers the ability to craft unit tests involving complex objects without risking the possible complications inherent in instantiating those objects. They can be used to test code’s behavior when things go wrong, when infrequent things happen, or when a complex system of objects needs to be in a specific state. They are good for testing methods that return non-deterministic results (like the current time), and standing in for objects you plan to build, but haven’t built yet. In short, they’re useful, but xCode does not support them out of the box.
Apple’s xCode ships with OCUnit which is “a faithful implementation of xUnit patterns for Objective-C”[Vollmer]. Though useful for testing (it provides the various combinations of assertions covering nulls, exceptions, true, false, and equality), it lacks the capability to produce mock objects. That’s where OCMock comes in. OCMock is a library that works with Objective-c and provides methods that allow you to employ mock objects throughout your own applications. In this post, I’ll be walking through the setup of OCMock in Apple’s xCode environment and running through a few basic use cases for the OCMock library.
Why Stakeholders Need To Be Involved In Scrum
Scrum is a procedure for producing software. It allows companies to respond quickly to change and leverage the unique skillsets of their employees to rapidly develop good solutions. While Scrum is designed to achieve agility, its implementation requires a high degree of rigidity to execute well. In this sense it is a process like any other; a set of rules that allows everyone involved to know what happens next, who they should go to with problems, and how to communicate effectively.
NuGet Config File Transformation Causes Duplicate Entries On Update
Problem Overview
First off NuGet is great. It has made life easier for me as a developer, and now, as an author for the open source generic repository SharpRepository. It provides a great distribution channel, especially for providing updates.
The NuGet packages for SharpRepository add configuration elements to your Web.Config or App.config to make your life easier and allow for a configuration file way of setting up your repository. NuGet provides a very simple configuration file transformation process when installing or updating a package. (For more information on it check here.) Basically it merges in your web.config.transform data into your web.config file adding the entries that don’t already exist.
Load Testing with Locust on Windows
The Point
Locust is, if you believe the hype, the HOLY GRAIL of obscure Python-based distributed load testing tools with real-time web-based statistics:

I’ve tried a few different times to get Locust up and running on Windows, and every time something has gone wrong enough for me to be demotivated and quit. ‘Cause, y’know, I’m a quitter.
Until now!
My goal is to help YOU get Locust setup on your Windows machine in the “recommended” way, so you can bring down your server by flooding it with thousands of requests too. There is something awe-some about having the power to bring down a server remotely just by typing “100,000” in the “How many users?” input box…
Writing A Custom LINQ Provider With Re-linq
Overview
When LINQ was first released in 2007, I remember thinking that I wouldn’t use it and I was very happy using SQL for querying the database. Well, once I started using it I really liked the ability to query lists, XML and SQL Server or other databases all using the same query syntax (for the most part at least). When starting the generic repository idea that became SharpRepository, it became a logical choice to use. If a backend had a LINQ provider then it became pretty simple to add it to our list of supported systems: Entity Framework, InMemory, Cache, RavenDB, MongoDB, and db4o all had LINQ providers that we could find, whether they were developed by the same group or a third party provider.
At some point I started thinking, “how can we integrate with a technology that doesn’t have a LINQ provider?” And the answer that came to me was, “I’ll just build one, it can’t be that hard right.” Well, turns out, it’s not the easiest thing to do. After doing some research, I came across this great article by Ayende Rahien about creating the LINQ provider for RavenDB and, as you can tell by the title, the difficulties which he faced: The Pain of Implementing LINQ Providers. In it, he refers to the re-linq framework which takes some of the pain out of the process.
AutoMapper Profile Organization
AutoMapper is a great tool that I use on every project I’m involved in. Primarily I use it to map my Model to my ViewModel when doing MVC development. If you haven’t used it before, I highly recommend checking it out.
If you’ve used AutoMapper before on a larger sized project, then you’ve probably seen how long and unruly your mapping definitions can become. This file can grow and grow and just be a pain to deal with. Luckily, AutoMapper provides a way to separate the definitions up into more logical units. When doing MVC development, it might be natural to group all the Model/ViewModel mappings for a single controller, but you can break it up however makes logical sense to you. You would do this by creating a custom Profile for each where you define your mappings for those entities.
Rails 3.2: A Nested-Form Demo Part 4: Switch to Targeting Computer!
Overview
Our heroes have fought their way through the Death Star’s fighter screen and can see the trench. As they enter the trench our pilots stabilize their deflector shields, preparing for the torrent of incoming turbolaser fire that will no doubt be coming their way.
In this post, we’ll take a look at adding some validation rules to our Ship and Pilot models. Hopefully, this effort will prevent our users from… err… having their way with our meek and rather naive Starfighter Recognition Guide. Our exhaust port is small, it’d be a shame to see it damaged by some ham-fisted users.
Validation
In our last post we walked away with a fully-functioning Starfighter Recognition Guide that could save a Ship and any changes (create/update/delete) to its associated Pilots. Neat, right?
Before we run off and save everything willy-nilly, we should probably go about checking to make sure our users provided the data we need. Let’s add some data entry requirements to our application, shall we? Here’s what we need to do:
Ship Requirements
- A
Shipmust have a name. - A
Ship‘s name must be between 3 and 50 characters. - A
Shipmust have a crew. - A
Shipmust have between 1 and 5 crew members.- Arbitrary? Sure. But I figure if a
Shiphas more than 5 crew members, it’s probably a capital ship or on a scale that isn’t appropriate for a Starfighter Recognition Guide.
- Arbitrary? Sure. But I figure if a
- A
Shipmust have a speed. - A
Ship‘s speed must be between 50 and 200… err… thingies per… umm… unit of time.- At the risk of having my Star Wars nerd card revoked, I’m not sure how the speed of a starfighter is measured. Yes, I looked it up. Nope, I couldn’t find anything conclusive.
SharpRepository: Configuration
If you haven’t read my introductory post on SharpRepository you should give it a quick read as it provides a nice overview of the basic usage of SharpRepository. In that post, I use the simplest method for creating my repository, I just new it up like so:
var orderRepository = new InMemoryRepository<Order>();
While this definitely works, it isn’t the best way. Why? Well, if you want to switch to an Ef5Repository or want to add caching, you will need to change the code and recompile. Plus, you are using dependency injection and inversion of control right? Well this doesn’t work with those patterns of course. In this post I will cover some of the various ways to create your repository.
Configuration Overview
Before getting into the code for loading up a repository via configuration settings it will be helpful to understand the SharpRepository hierarchy. Each repository has a specific type of backend that it queries (e.g. InMemory, Entity Framework, RavenDb, MongoDb, Db4o, Xml, etc.), a caching strategy (e.g. None, Standard, Timeout), and a caching provider (e.g. Memory, memcached, Azure, etc.).
The caching strategy tells the repository the rules for caching. The Timeout Strategy uses a simple time based rule, for example, cache the query results for 30 seconds, while the Standard Strategy uses Generational and Write-Through caching techniques to provide a more sophisticated caching logic. And the No Caching Strategy does not do any caching at all (it’s not just a clever name).
The caching provider on the other hand is the specific cache technology that is used. For simple websites the InMemory caching provider works great and uses the ASP.NET built-in System.Runtime.Caching.MemoryCache. For more advanced needs like distributed caching you would use the memcached provider or the Windows Azure provider and store the cache across multiple servers.
The beauty of this is that both of these can be extended by inheriting from ICachingStrategy or ICachingProvider if the need arises.
Rails 3.2: A Nested-Form Demo, Part 3: We’re Starting Our Attack Run!
Overview
When we last left our heroes, they fought their way through the superstructure of our application and were setting up to finish it off. Having defeated the TIE fighter screen, our intrepid fighter pilots have descended into the trench of the Starfighter Recognition Guide. Their computers are locked, they’re getting a signal…
In this post, we’ll capitalize on the code and plumbing we implemented here and here. We’ll take a look at the views we put in place and some javascript to make our Starfighter Recognition Guide a bit fancy-pants.
Stabilize your rear deflectors and watch for enemy fighters – there’s gonna be a tubolaser battery’s worth of code in this one.
Rails 3.2: A Nested-Form Demo, Part 2: Accelerate to Attack Speed!
Overview
In our previous post, our intrepid heroes were hurtling headlong into the trenches of the Starfighter Recognition Guide. They maneuvered through the superstructure of the application, setting up a relationship between themselves (the Pilots) and the Ships they fly. In this post, our ace Rebel pilots will make their approach to the surface of our application.
The Controller
Because all of the heavy lifting is being handled by the ActiveRecord configuration defined in our domain model, the controller for the Ship model is pretty standard fare. As a quick refresher, here’s what the create method in the ships_controller looks like:
def create
@ship = Ship.new(params[:ship])
if @ship.save
redirect_to(ships_path, :notice => "The #{ @ship.name } ship has been saved successfully.")
else
render(:new, :error => @ship.errors)
end
end
If you’re interested in looking at the controller in its entirety, you can check it out here.
Recent Posts
- iOS Unit Testing With OCMock
- Why Stakeholders Need To Be Involved In Scrum
- NuGet Config File Transformation Causes Duplicate Entries On Update
- Load Testing with Locust on Windows
- Writing A Custom LINQ Provider With Re-linq
- AutoMapper Profile Organization
- Rails 3.2: A Nested-Form Demo Part 4: Switch to Targeting Computer!
- SharpRepository: Configuration
- Rails 3.2: A Nested-Form Demo, Part 3: We’re Starting Our Attack Run!
- Rails 3.2: A Nested-Form Demo, Part 2: Accelerate to Attack Speed!
- Rails 3.2: A Nested-Form Demo, Part 1: All Wings Report In!
- iOS Behind the Curve
- Distributed Transaction Coordinators, Port 135, and Firewalls – Oh My!
- SharpRepository: Getting Started
- Find Performance Problems Using JMeter, MySQL and Xdebug/Webgrind
- Taming Hot Key Context Shifting When Running A Windows VM In Virtualbox On OSX
- Integrating Twitter’s Bootstrap Into Your Project
- Mobile payments, tags and more using NFC
- Stress Pig
- Dear Client Services, What Works?
- What Would Steve Do?
- Still Using Fiddler to Test & Debug Your REST Services?
- Write-through and Generational Caching Make a Great Team
- Thinking Recursively
- Development Incentives, What’s the Payoff?
- How do you like them Apples?
- “Optional” Software Development Practices Series — Code Review
- Adding Images to Select Lists in MVC3
- “Optional” Software Development Practices Series
- You Get What You Pay For…
- Outsourcing Safety Tips
- Facebook IPO
- The Ballad of Tim Toady
- The Little Schemer
- Newsflash: Mom leaves tech job at 5p.m.
- Flashback!
- I <negative_emotion> Windows 8!
- Prefix vs. Postfix Increment and Decrement Operators in C++
- Corporate videos: viral boon or epic fail?
- Recruitin’ Time!
- Reference vs. pointer parameters in C++
- The IE8 "hover" Bug: The Most Awesome IE Bug Ever?
- When is perfect perfect enough?
- SOPA/PIPA: Anti-Censorship Protest or Techies Revenge?
- A Decade of Fairway
- Handling Session Timeout Gracefully
- Generating Software Diagrams
- The Audacity of Nope
- The Origins of Culture
- Scrum Overview in Prezi – not another boring slideshow
- Numbers don’t lie: LinkedIn Statistics
- What is your favorite software development tool?
- Best Practices for Selecting Onshore, Nearshore or Offshore Information Technology Outsourcing (ITO) Providers
- Sign of the Times
- Advantages and Risks of Offshoring, Nearshoring or Onshoring
- Does Outsourcing Mean Offshoring?
- Too little, too late?
- New Favorite Lunch Spot
- Why should I care about functions as first-class citizens?
- PHP Remote Debugging with XDebug and NetBeans
- Installing SubText with Web PI
- ROI Primer
- Learn Domain-Driven Design
- Learn Behavior-Driven Development
- Mario Kart Tournament
- F# in 90 Seconds
- Website Vulnerabilities
- Scrum Overview
- Language Club
- Top 12 Favorite Podcasts Ever…
- Fairway Dart Tournament
- Learn Lean Software Development and Kanban Systems
- Android – Eclipse Quick Start
- Learn Functional Programming
- Backup & Restore Strategy
- Smartphone Screens – Another Wireless Variable
- Wireless Application Market
- Head First AOP





