Showing posts with label Testing. Show all posts
Showing posts with label Testing. Show all posts

Friday, July 27, 2012

Dynamic Test Data Using Rhino.Mocks Do() Method

Scenario: You need to test a controller action that updates a set of data, then redisplays the page with that updated data. You want to stub out the code that actually executes the update so that it returns test data, but you need your stub to mimic the update functionality to prove that the updated data is getting re-displayed.

How I Did It:
The challenge here is making your test data mimic the same changes without using the actual update code. We're testing the controller here - the update code gets tested separately - and separation of concerns is a Good Thing. So how do we use arbitrary custom behavior on our mocked class when our system under test calls the update method?