Tag Archive for visual studio

Provide unit test is not a guarantee of unit testing

In the last years we’ve been hearing a lot about unit testing, so much that now is in the mouth of almost every big or small software company. It’s even so common that many are so brave to say: “If you don’t provide unit tests for your code, then it’s worthless”.

Well, I would be even more brave and say: “If you provide unit tests with your code, even your templates, those test should be worth a penny”.

I found this wonderful piece of code today from a project template:

[TestClass]
public class PackageTest {
    [TestMethod]
    public void CreateInstance() {
        var package = new Walkthrough_01Package();
    }

    [TestMethod]
    public void IsIVsPackage() {
        var package = new Walkthrough_01Package();
        Assert.IsNotNull(package, "The object does not implement IVsPackage");
    }

    [TestMethod]
    public void SetSite() {
        // Create the package
        IVsPackage package = new Walkthrough_01Package();
        Assert.IsNotNull(package, "The object does not implement IVsPackage");

        // Create a basic service provider
        OleServiceProvider serviceProvider = OleServiceProvider.CreateOleServiceProviderWithBasicServices();

        // Site the package
        Assert.AreEqual(0, package.SetSite(serviceProvider), "SetSite did not return S_OK");

        // Unsite the package
        Assert.AreEqual(0, package.SetSite(null), "SetSite(null) did not return S_OK");
    }
}

Ok, let’s just rewrite this test for the sake of just see how would it look like:

public class SamplePackageFacts {
    private readonly IVsPackage _package = new Walkthrough_01Package();

    [Fact]
    public void PackageCanCorrectlySetSiteFromProvider() {
        var site = OleServiceProvider.CreateOleServiceProviderWithBasicServices();
        var answer = _package.SetSite(site);
        Assert.Equal(VSConstants.S_OK, answer);
    }

    [Fact]
    public void PackageCanCorrectlySetNullProvider() {
        var answer = _package.SetSite(null);
        Assert.Equal(VSConstants.S_OK, answer);
    }
}

Can you spot the problem? do you see any value at all in the original three tests methods?

NOTE: I used xUnit just because I like it. It’s not a problem inherited from using the test framework but from the way of look at what is a unit test, you could do exactly the same using MSTest.

JustCode is not loading in Visual Studio 2011

Telerik’s JustCode it’s an awesome product, it’s a very lightweight extension that may lack some features (sorry, I won’t mention names) but it does its job, and that’s good. Almost a month ago Telerik announced JustCode support for Visual Studio 2011, that’s awesome, specially when I decided to try out Visual Studio 2011 in a pristine installation inside a virtual machine (and yeah, I know other extensions already announced the same).

installer

I downloaded the JustCode internal build and the installer correctly detected my Visual Studio 2011 installation, sweet, everything finished without any problem. Then when I started Visual Studio 2011 I realized JustCode didn’t load… and all what I get it’s a very verbose exception in the JustCode’s output window:

ERROR 2011-10-23 00:23:38.842 :  [HResult: 80131602]
System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
   at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
   at System.Reflection.RuntimeModule.GetTypes()
   at System.Reflection.Assembly.GetTypes()
   at System.ComponentModel.Composition.Hosting.AssemblyCatalog.get_InnerCatalog()
[and a lot of more lines...]

I submitted some bug tickets, write to some Telerik’s developers but no right answers, you know, the usual.

Well, I decided to see what’s happened, so I did what every other developer would do, attach your debugger to Visual Studio and then found the issue. JustCode is trying to load the assembly Microsoft.VisualStudio.CSharp.Services.Language, Version=10.0.0.0 but in a machine without Visual Studio 2010 this assembly didn’t exist, it’s unique of a Visual Studio 2010 installation. Of course, I’m using a Virtual Machine snapshot, I don’t have a previous version installed. The assembly present in my VS2011 installation is Version=11.0.0.0.

The easy way to fix it? Go to a Visual Studio 2010 installation, copy the assembly Microsoft.VisualStudio.CSharp.Services.Language.dll from the Common7 directory and paste into your Telerik’s JustCode directory, that’s all, JustCode now it’s going to load. Maybe this would cause some other problems, but come on, it was my first attempt! =)

Probably a better way to fix it would be using assembly binding redirection, or taking care of the fact that maybe a previous installation it’s not present maybe in the installation process. I’m just saying!

Note for developers in general: it’s a good idea to test your installation in a pristine installation before release it to the wild, just to see what’s happening, you know, just in case =)

Lanzamiento de Visual Studio 2010 en la comunidad

Hace poco más de una semana se llevó a cabo el lanzamiento comunitario de Visual Studio 2010 en la Ciudad de Guatemala, junto con compañeros como Carlos Lone (Microsoft Client Application Development MVP) y Manolo Herrera (Microsoft Sharepoint MVP) tube el honor de presentar las nuevas características y ventajas de esta nueva versión de ASP.NET 4.0 y Visual Studio 2010.

Como alguno siempre me pide las diapositivas de la presentación, se las dejo para que puedan descargarlas (en Slideshare).

Ver diapositiva en Slideshare.net

¡Saludos!

Lanzamiento de la Comunidad y Visual Studio 2010

Como ustedes habrán notado la comunidad ha estado en un estado de "pausa" por los últimos meses. Para aprovechar el momentum hemos estado organizando un evento de lanzamiento para Visual Studio 2010 a nivel comunitario. Los dejo con la información :)

Lugar: Oficinas de Microsoft, Edificio Torre Citibank (Intercontinental) [3a Avenida 13-78 Zona 10, Of 1101, Guatemala]

Fechas: Miércoles 23, Jueves 24, Viernes 25 de Julio

Horas: de 6pm a 9pm

Expositores y temas

Silverlight/WPF 4.0 Development

Expositor: Carlos Lone, Microsoft MVP Client Application Development, http://weblogs.asp.net/carloslone/

Fecha: Miércoles 23 de Junio

La nueva era de websites en el internet cada vez más demandan la inclusión de una mejor experiencia de usuario (UX) en donde la interactividad, contenido multimedia y uso del sitio sea más sencillo y amigable para los usuarios.

Se ha dicho de que las versiones anteriores de Silverlight estaban muy orientadas a relizar animaciones y a presentar imagenes  y videos con mejor definición. Sin embargo desde la versión 3.0 y ahora en la versión 4.0 la capacidad de poder utilizar esta herramienta para hacer aplicaciones de linea de negocio es cada vez más sencillo.

Acompañanos a descubrir todas las novedades de Silverlight y WPF en VS2010

- Demistificando Silverlight y WPF 4.0

- Novedades

- Construcción de aplicaciones de linea de negocio.

- Construiremos una aplicación 0 a 100.

Sharepoint 2010 Development

Expositor: Manolo Herrera, Microsoft MVP Sharepoint, http://jmhogua.blogspot.com/

Fecha: Jueves 24 de Junio

El desarrollo en SharePoint nunca antes ha sido tan fácil y práctico

- Desarrollando en Web Part Visual para SharePoint en 15 minutos

- Depurando e instalando tu código en SharePoint desde Visual Studio con presionar una sola tecla.

- Descubriendo el nuevo Developer Dashboard de SharePoint

- Conociendo el Client Object Model de SharePoint desde un aplicación Windows.

- Creando una Sandbox Solution para que nos sirve y ayuda.

Web development con ASP.NET 4.0

Expositor: Cristian Prieto, Microsoft MVP ASP.NET, http://www.cprieto.com

Fecha: Viernes 25 de Junio

ASP.NET ha evolucionado muchísimo en los últimos años con la adición de ASP.NET MVC y Dynamic Data, además de las mejoras continuas a la plataforma de WebForms y ASP.NET AJAX. Hablaremos de como aumentar la productividad y al mismo tiempo construir aplicaciones web que manejen de una manera transparente CSS, controles finos sobre el renderizado y markup al mismo tiempo que podemos mejorar SEO y muchas otras características nuevas en ASP.NET 4.0

 

El cupo es limitado, así que sugiero que corran al link de registro y aparten su lugar http://bit.ly/launchgt

¡Espero verlos en el lanzamiento!

NOTA: Recuerden imprimir y llevar al evento el ticket de inscripción que se genera en el momento del registro

Saludos,