Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XS✔ ◾ Add comment to IApiMarker example #8114

Merged
merged 4 commits into from Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Binary file not shown.
16 changes: 13 additions & 3 deletions rules/use-iapimarker-with-webapplicationfactory/rule.md
Expand Up @@ -14,7 +14,7 @@ redirects:
The `WebApplicationFactory` class is used for bootstrapping an application in memory for functional end to end tests. As part of the initialization of the factory you need to reference a type from the application project.

Typically in the past you'd want to use your `Startup` or `Program` classes, the introduction of top-level statements changes how you'd reference those types, so we pivot for consistency.

<!--endintro-->

Top level statements allows for a cleaner `Program` class, but it also means you can't reference it directly without some additional changes.
Expand Down Expand Up @@ -47,8 +47,18 @@ This approach means you don't need to do all the InternalsVisibleTo setup, but d

The `IApiMarker` interface is a simple interface that is used to reference the application project.

```cs
namespace RulesApi;

// This marker interface is required for functional testing using WebApplicationFactory.
// See https://www.ssw.com.au/rules/use-iapimarker-with-webapplicationfactory/
public interface IApiMarker
{
}
```

::: good
![Figure: Good example - Using an IApiMarker interface](Using-IApiMarker-interface.jpg)
Figure: Good example - Using an `IApiMarker` interface
:::

Using the `IApiMarker` interface allows you reference your application project in a consistent way, the approach is the same when you use top level statements or standard Program.Main entry points.
Using the `IApiMarker` interface allows you reference your application project in a consistent way, the approach is the same when you use top level statements or standard Program.Main entry points.