Pregunta

Aquí está el código.¡GetParentPath se llama según NORMAL!

    [TestMethod]
    [HostType("Moles")]
    public void GetParentPath_slashOnEnd_returns()
    {
        var sapi = new MPhotobucketApi();
        sapi.GetParentPathString = s => s;

        var api = new PhotobucketApi();
        var parentPath = api.GetParentPath("hello/world/");

        Assert.AreEqual(parentPath, "hello");
    }

¿Fue útil?

Solución

La forma en que escribió su prueba, su redirección solo se aplica a la instancia de tiempo de ejecución incrustada en SAPI.Debe interceptar el constructor de Photobucketapi e interceptar la instancia 'Future' de Photobucketapi allí:

MPhotobucketApi.Contructor = (me) => {
    new MPhotobucketApi { GetParentPathString = s => s }; 
};
...

El Otro Apuro es redirigir a GetParentPath para todas las instancias haciendo esto:

MPhotobucketApi.AllInstances.GetParentPathString = (me, s) => s;
...

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top