Skip to content

Commit

Permalink
Coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaliumhexacyanoferrat committed Nov 28, 2024
1 parent 5b8b31f commit e9d5d67
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
13 changes: 2 additions & 11 deletions Adapters/AspNetCore/Adapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,14 @@ namespace GenHTTP.Adapters.AspNetCore;
public static class Adapter
{

public static void Map<T>(this WebApplication app, string path, IServerCompanion? companion = null) where T : IHandler, new()
=> Map(app, path, new T(), companion);

public static void Map(this WebApplication app, string path, IHandlerBuilder handler, IServerCompanion? companion = null)
=> Map(app, path, handler.Build(), companion);

public static void Map(this WebApplication app, string path, IHandler handler, IServerCompanion? companion = null)
=> app.Map(path + "/{*any}", async (context) => await Bridge.MapAsync(context, handler, companion: companion, registeredPath: path));

public static void Run<T>(this IApplicationBuilder app, IServerCompanion? companion = null) where T : IHandler, new()
=> Run(app, new T(), companion: companion);

public static void Run(this IApplicationBuilder app, IHandlerBuilder handler, IServerCompanion? companion = null)
=> Run(app, handler.Build(), companion: companion);

public static void Run(this IApplicationBuilder app, IHandler handler, IServer? server = null, IServerCompanion? companion = null)
=> app.Run(async (context) => await Bridge.MapAsync(context, handler, server, companion));
public static void Run(this IApplicationBuilder app, IHandler handler, IServer server)
=> app.Run(async (context) => await Bridge.MapAsync(context, handler, server));

public static IHandlerBuilder<T> Defaults<T>(this IHandlerBuilder<T> builder, bool errorHandling = true, bool compression = true, bool clientCaching = true, bool rangeSupport = false) where T : IHandlerBuilder<T>
{
Expand Down
11 changes: 9 additions & 2 deletions Testing/Acceptance/Adapters/AspNetCore/IntegrationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public async Task TestDefaults()

var options = (WebApplication app) =>
{
app.Map("/content", Content.From(Resource.FromString("Hello World")).Defaults());
app.Map("/content", Content.From(Resource.FromString("Hello World")).Defaults(rangeSupport: true));
};

await using var app = await RunApplicationAsync(port, options);
Expand Down Expand Up @@ -96,7 +96,14 @@ public async Task TestImplicitServer()

var options = (WebApplication app) =>
{
app.Map("/server", Inline.Create().Get((IRequest r) => r.Server));
app.Map("/server", Inline.Create().Get(async (IRequest r) =>
{
await r.Server.DisposeAsync(); // nop

await Assert.ThrowsExceptionAsync<InvalidOperationException>(async () => await r.Server.StartAsync());

return r.Server;
}));
};

await using var app = await RunApplicationAsync(port, options);
Expand Down

0 comments on commit e9d5d67

Please sign in to comment.