Ir al contenido principal

Unit Testing SharePoint 2010 con Visual Studio 2012 Ultimate

Para crear pruebas unitarias para código SharePoint 2010 se requiere de Visual Studio 2012 Premium/Ultimate que contiene el framework Microsoft Fakes,
Para realizar una prueba de como funciona seguí este ejemplo 

Sin embargo no encontré el código para compilarlo; por lo tanto cree un proyecto de web part visual, y agregué los métodos sobre los cuales se hacen las pruebas que aparecen en la página; allí vienen dos métodos de ayuda en la clase de pruebas que tampoco son listados y deben ser algo así:

public SPList AddListToSiteHelper(SPSite site)
        {
            // create a new temporary list              

            SPWeb web = site.RootWeb;
            var listId = web.Lists.Add("test", "test", SPListTemplateType.GenericList);
            SPList list = site.RootWeb.Lists[listId];
            Assert.IsNotNull(list);

            return list;
        }

private void AddItemsToListHelper(SPList list, string[] fields)
        {
            SPListItem item = list.Items.Add();
            item["Name"] = fields[0];
            item["Phone"] = fields[1];
            item["Email"] = fields[2];
            item["Age"] = fields[3];
            item["Date"] = fields[4];
            item.Update();
        }

También hay que verificar cuando creas el proyecto de Test que sea en el Framework 3.5, de lo contrario creo que no funcionará.

Comentarios

Entradas populares de este blog

Ubuntu 12.04 Wireless reconexión

Instalé ubuntu 12.04 ayer por la noche. todo funciona bien, casi perfecto, excepto que hoy en la mañana después de abrir muchas páginas, apt-get etc al mismo tiempo creo que hizo que el wireless se desconectase y aunque me preguntó mil veces el password nunca pudo conectarse; ver los logs con gnome-system-log no fue de gran ayuda simplemente mostraba time-out's después de 100 intentos...la solución reboot... casi como windows7 :( eso funcionó...posteriormente volvió a pasar....no quiero rebootear... es linux asi que unos mans sobre modprobe, lsmod comandos de modulos me llevó a esta solución... Aplica para mi Toshiba satellite A505: Primero listar todos los módulos cargados $lsmod encontré los módulos posibles que son del wireless: cfg80211, consulte información para descargarlos $ man modprobe ahí una referencia mas directa para descargar módulos $ man rmmod luego intentar (sólo aplica a la toshiba que tengo --latinoamerica) $ sudo rmmod -v cfg80211 envía ERRO...

GNUstep ProjectCenter/Gorm/AClock running Ubuntu 10.04

Download sources GNUstep (stable or unstable) to compile; Dependencies First you need to check dependencies in ubuntu and install with sudo apt-get or search before with apt-cache command; almost every package ends with *-dev in ubuntu repositories this command will install all dependencies for compile: ~$ sudo apt-get install libffi-dev libssl-dev libxml2-dev libxslt1-dev libcairo2-dev libxt-dev GNUstep Make compiling GNUstep make is our first target; it's the primary package to compile GNUstep applications. get the package, untar and change into the folder and compile: ~$wget ftp://ftp.gnustep.org/pub/gnustep/core/gnustep-make-2.4.0.tar.gz ~$tar xzvf gnustep-make-2.4.0.tar.gz ~$cd gnustep-make-2.4.0/ ~$./configure --prefix=/usr/local/GNUstep/ --enable-native-objc-exceptions ~$make ~$sudo make -E install *NOTE: the options /usr/local/GNUstep/ is the folder where all the GNUstep is going to install. the second option --enable-native-objc-exceptions enable th...