Skip to content

Generated documentation for injecting services in tests contains small error #1742

@RiRiSharp

Description

@RiRiSharp

Go to https://bunit.dev/docs/providing-input/inject-services-into-components.html#injecting-services-in-tests then the code example looks like

  Services.AddSingleton<IWeatherForecastService>(new WeatherForecastService());

  // RenderComponent will inject the service in the WeatherForecasts component
  // when it is instantiated and rendered.
  var cut = RenderComponent<WeatherForecasts>();

  // Assert that service is injected
  Assert.NotNull(cut.Instance.Forecasts);
}

If we look to the actual file which generated this sample then we observe no errors there.

We'd expect the generated documentation to look like

Services.AddSingleton<IWeatherForecastService>(new WeatherForecastService());

// RenderComponent will inject the service in the WeatherForecasts component
// when it is instantiated and rendered.
var cut = RenderComponent<WeatherForecasts>();

// Assert that service is injected
Assert.NotNull(cut.Instance.Forecasts);

Let me know if there's a fix I can do.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions