A controversial alternative for you - do not use mocks!
Instead, do integration testing, because indeed, once you use SharePoint OM, this is what you do.
Put most of your logic in library assemblies that can be run from outside the Context request (overload constructor for passing to HttpContext or SPWeb).
Configure the server / site (it is advisable that you can roll back and create new instances) only for unit tests and run against it. ( VMWare server is free)
If you are performing a continuous build, you should be able to run it automatically and report the results. Alternatively, you can use some of the magic of the open source batch file nUnit or your tool to run tests as soon as the new .dll is copied at the PostBuild stage.
disadvantages
You have a bit of work setting up data for your tests (although it is much more than getting bullying working?)
Not everything can be tested as follows
It may take a little longer to start, but if you work as part of a continuous build, is this a problem?
The team requires more discipline so as not to step on other fingers of people.
Benefits
Testing against real SharePoint OM with all its incomprehensible inconsistencies and special cases (if you were unkind, you can call them errors;)
Who knows what parts of OMβs behavior can subtly change when new service packs / cumulative updates appear, this should help to catch any violations.
- When SharePoint 2010 appears, you can run your tests against 2007 and 2010, see what has changed, make sure your library works with both versions (if this suits your project)
The compromises for all projects are different, but for my projects I prefer security, knowing that I am testing the real thing - call me old-fashioned if you do!
source share