Sitecore Code Challenge 1

Posted by Robin Hermanussen on December 14, 2014 · 2 mins read

Someone once told me about Pex for fun. And ever since, I occasionally visit the website to solve some C# coding puzzles. Essentially, it requires you to implement some code and have unit tests for it pass. But you don’t know the implementation of the unit tests.

I thought about how we could do something similar with Sitecore, and came up with a way to do it. If you follow the steps below, you’ll have a .sln with a project that compiles and has unit tests. But the tests all fail.

It’s your job to make sure the code passes the unit tests. But the relevant code in the unit tests is hidden inside an obfuscated DLL (can’t be easily decompiled).

The failing assertions  in the unit tests, will give you detailed hints though. And if you succeed in getting the unit tests to pass, your project can be deployed to Sitecore and will actually be usable!

Since this is quite a new way of getting to know Sitecore in a fun way, I’m bringing this to the community as an experiment. I’m very interested to learn your experiences:

  • Are you able to finish the puzzle?
  • Is it fun trying to solve the puzzle?
  • Any feedback for creating a second challenge (if this one turns out to be a success)?

Follow these steps to get started:

  1. Download this ZIP file and extract it.
  2. Copy “Sitecore.Kernel.dll” to the folder “Binaries” (I’ve tested with version 7.2 rev 140526, but it will probably work with other versions as well).
  3. Open the project in Visual Studio and build the project.
  4. Run the unit tests using a runner that supports xUnit (I’m using xUnit.net VS runner, which is free)
  5. The tests are ordered into steps. Go through the steps in  order and look at the reported errors for hints on how to solve the puzzle.

Let me know if you are able to finish this first code challenge! Have fun!