# 10.5.2 Configurando el objeto para sustituir mensajes de Error por idioma

Para esto necesitamos obtener acceso a la clase **Startup.cs** de nuestro proyecto CaducaRest para poder obtener un objeto de la clase **LocService**.&#x20;

Crea una nueva clase llamada **MockLocService.cs** en el proyecto **xUnit.CaducaRest** y con el método WebHostBuilder puedes configurar la forma de mandar llamar a tus servicios y obtener cualquiera de los objetos necesarios para correr tus servicios y sustituirlos por otros. En este caso vamos a traer el objeto LocService.

{% code title="MockLocService.cs" %}

```csharp
public class MockLocService
{
    public LocService ObtenerLocService()
    {
        var builder = new WebHostBuilder()
                        .UseStartup<Startup>()
                        .ConfigureAppConfiguration((context, config) =>
                        {
                            config.SetBasePath(Path.Combine(
                                Directory.GetCurrentDirectory(),
                                "..", "..", "..", "..", "CaducaRest"));
                            config.AddJsonFile("appsettings.json");
                        });
        var scope = builder.Build().Services.CreateScope();
        return scope.ServiceProvider
                            .GetRequiredService<LocService>();
    }
}
```

{% endcode %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://abi.gitbook.io/net-core/8.-pruebas-unitarias/8.5-configurando-clases-para-objetos-sustitutos/8.5.2-configurando-el-objeto-para-sustituir-mensajes-de-error-por-idioma.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
