Having just had the unfortunate need to use rhino mocks from managed C++ I thought I would document the “how”
Let’s say you want to mock/stub IFoo. Which has two methods:
- IQux Bar()
- int Baz(int)
Create a MockRepository:
IFoo^ foo_stub = MockRepository::GenerateStub<IFoo^>();
Stub out Bar() -> Note it doesn’t take a parameter:
Rhino::Mocks::Function<IFoo^, IQux^>^ foo_bar =
gcnew Rhino::Mocks::Function<IFoo^, IQux^>(&IFoo::Bar);
RhinoMocksExtensions::Stub(foo_stub, foo_bar)->Return(
/* Another mock/stub or a real IQux */
);
Stub out Baz() -> Note it takes a parameter:
Note, the static method, this will configure the stub for a specific argument, in this example when Baz(1) is called we return 2.
Rhino::Mocks::Function<IFoo^, int>^ foo_baz =
gcnew Rhino::Mocks::Function<IFoo^, int>(&Test::FooStubBaz);
RhinoMocksExtensions::Stub(foo_stub, foo_baz)->Return(2);
// IFoo will actually be a rhino mock/stub
int Test::FooStubBaz(IFoo^ foo) {
return foo->Baz(1);
}
Now foo_stub->Baz(1) will return 2
I imagine you could remove the need for a static method but this was enough for my needs and my head!
I have recently been playing with the NeuroSky mindset – I have always found this subject fascinating…
Unfortunately the device didn’t come with any Linux software so I decided to write some using ruby. Had a good run at coding this weekend and I’m now finalising the gem – Hope to have it up on git hub and ruby forge this week. I can then move onto coding some fun software on top. Doubt it will have a huge demand but at least it will make using the device a little easier on Linux (and Windows), I needed it so at least one person will benefit!
Update: I have placed an almost finished (just some documentation tidying left) version on GitHub
I’ve been thinking about agile/LEAN feedback loops lately, primarily how I could introduce fun ways to kick start them and hopefully keep them maintained. With this in mind my thoughts turned to the “commit” process. It’s something all developers do (hopefully else your coding without revision control) and provides a nice point in time to inject some automated feedback.
The idea is to have each commit analysed for some simple “agile” metrics, nothing too complex or tricky, examples:
- Did the commit touch unit tests
- Was the commit “small”
I imagine you could also run a few simple code quality algorithms also (ones that are regarded as being sensible) and maybe a copy and paste checker. Overall the main aim is to find around three or four simple metrics that the team can agree on that signify good practice.
Then the fun starts, you normalise the values and plug them into a simple fighting game, where they impact the fighters abilities (and looks?), clearly weighted towards the better the metrics, the better the fighter. This new fighter then battles the current one (winner of the last commit war) to see who remains king of the hill.
The whole fight can be e-mailed back as a small movie, statistics can also be kept – If you commit small, unit tested code often you have a high chance of ranking highly.
Think I will code this up. Also wondered about wiring the commit to net hack or an adventure game, I.e. your commit log would contain a string for your next move, on commit you are e-mailed a response. E.g.
# open door <commit> "You see a wolf"
Fun, possibly, but not where I was heading.
Current search engines replicate L-Mode thinking – Linear and logical. I type in “pie” and I get things directly associated with the search term. Practical, but dull!
Tangential is R-mode thinking (albeit in a simplified form). Taken to its extreme an R-mode search engine would take the word “pie”, “think” on it and return numerous interesting connections and patterns many appearing unrelated, yet on deeper inspection they are seen to weave in and around the search focus.
I feel the need to expand on Tangential. Unfortunately I don’t have enough skills or knowledge of the human language.
It started with a conversation in a pub (don’t most things?) related to porting “old” code to newer languages. With my interest in TinyMud I decided to take on the challenge of porting the original c-code to Ruby.
This is now becoming an intense labour of love! I’m wrapping the old TinyMud code as Ruby extensions and writing as many test cases as I can. I’m over half way through now. The idea being to get good test coverage of the c-code (in Ruby) then switch to Ruby equivalent code – Then re-factor to a more Ruby’esque style.
I have to say I’m impressed by the original source code (although I’m finding some edge case defects). I wonder if the Ruby code will be any more compact? Intending to put the result on GitHub at some point – For now it’s a one man mission!
Once complete I will run this on a server and prove wikipedia (sort of) wrong, I quote “No active games currently run on a TinyMUD server”. I could host the original (and I’m in a position to), but I think running a modernised equivalent would be more interesting.
Routinely purchase prices total to an important/note-worthy historical date, e.g. £10.66. I would therefore like till receipts, or tills themselves (to save paper) to recount an interesting historical fact based on the sum total to pay. “Oh, did you know on this date X happened”…
Whilst working on improving Poodle’s crawler I ran into a nasty problem. I had multiple threads all producing and consuming content from a shared “queue”.

It’s taken me more than my highly underestimated “few days” to complete, but I now have a version of my ruby based search tool up on github, it’s called “Poodle”. Feel free to use/contribute to, more information here.
It still requires some more work (hence the “0.9″ revision number), hopefully someone else will find it of use and help out.
I have been researching search tools for our Intranet/enterprise, after looking at Nutch, MS search server 2010 (express) and plenty of others I decided to write my own, why? A fair question, basically they all had something not quite right about them, varying from rubbish web-front ends to an inability to authenticate with NTLM or go through proxies. Lastly, I thought it would be fun!
The result – I’m almost done, 3 hours of coding! I didn’t start from scratch though, I wrote a simple ruby crawler, wired it to Apache Solr and wrote a rails application to call out to Solr and display the results (no rails database involved – Which differs from the normal RoR and Solr configuration). The RoR application even supports open-search.
The result is excellent! Just fine tuning now and tidying, I will put the code up in a day or two – It will be instructive if nothing else…
[The code is now on Github: https://github.com/mangled/Poodle]
Just goes to show how little programming I have done of late… At the weekend I built a ladder (picture below), it’s wonky but functional (like my code)! With Autumn closing in I feel the urge to get back coding, hopefully the next post will be more interesting…

Ladder






