The site is going to go into maintenance mode for a minute in order to fix some of the missing page attributes left over from the 3.0 WordPress upgrade.
I am still at my client Pexing out. It’s really neat to explore this whole new framework but honestly I am starting to get a little bored writing nothing but tests, even though Pex makes it a little better.
One problem I ran into when building the tests for my client was Pex was barfing because could not a factory that was located in a satellite Pex assembly. The only way that I could seemingly get it to work was to use to copy the relevant class to the other main Pex assembly, but this is terribly because not having the ambiguous references is pretty bad.
This is fixable however through the use of the assembly level PexExplorableFromFactoriesFromType and PexExplorableFromFactoriesFromAssembly attributes which allow you to specify factory methods to use in a declarative fashion.
This looks like the following:
Addition of the above will allow the mining of the appropriate factory methods.
A friend just asked me the way to cast a SPList To a SPDocumentLibrary so that he could access the document library specific attributes for document library objects. This is one way of doing it:
public static SPWeb GetWeb(string url)
using (SPSite site = new SPSite(url))
using (SPWeb web = site.OpenWeb())
public static SPDocumentLibrary CastDocumentLibrary(string url, string libraryName)
return GetWeb(url).Lists[libraryName] as SPDocumentLibrary;
Obviously, the casting can take on many forms, but the end result is still an SPDocumentLibrary object.