Skip to content

Commit ded18f3

Browse files
Fix options coverage
1 parent 01b2a91 commit ded18f3

File tree

2 files changed

+30
-8
lines changed

2 files changed

+30
-8
lines changed

tests/ImageSharp.Web.Tests/TestUtilities/AzureBlobStorageCacheTestServerFixture.cs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
// Copyright (c) Six Labors.
22
// Licensed under the Apache License, Version 2.0.
33

4+
using System;
45
using System.Threading.Tasks;
56
using Azure.Storage.Blobs.Models;
67
using Microsoft.AspNetCore.Builder;
8+
using Microsoft.AspNetCore.Http;
79
using Microsoft.Extensions.DependencyInjection;
810
using SixLabors.ImageSharp.Web.Caching.Azure;
911
using SixLabors.ImageSharp.Web.DependencyInjection;
12+
using SixLabors.ImageSharp.Web.Middleware;
1013
using SixLabors.ImageSharp.Web.Providers;
1114
using SixLabors.ImageSharp.Web.Providers.Azure;
1215
using Xunit;
@@ -19,16 +22,20 @@ protected override void ConfigureServices(IServiceCollection services)
1922
{
2023
services.AddImageSharp(options =>
2124
{
25+
Func<ImageCommandContext, Task> onParseCommandsAsync = options.OnParseCommandsAsync;
26+
2227
options.OnParseCommandsAsync = context =>
2328
{
2429
Assert.NotNull(context);
2530
Assert.NotNull(context.Context);
2631
Assert.NotNull(context.Commands);
2732
Assert.NotNull(context.Parser);
2833

29-
return Task.CompletedTask;
34+
return onParseCommandsAsync.Invoke(context);
3035
};
3136

37+
Func<ImageProcessingContext, Task> onProcessedAsync = options.OnProcessedAsync;
38+
3239
options.OnProcessedAsync = context =>
3340
{
3441
Assert.NotNull(context);
@@ -38,24 +45,28 @@ protected override void ConfigureServices(IServiceCollection services)
3845
Assert.NotNull(context.Extension);
3946
Assert.NotNull(context.Stream);
4047

41-
return Task.CompletedTask;
48+
return onProcessedAsync.Invoke(context);
4249
};
4350

51+
Func<FormattedImage, Task> onBeforeSaveAsync = options.OnBeforeSaveAsync;
52+
4453
options.OnBeforeSaveAsync = context =>
4554
{
4655
Assert.NotNull(context);
4756
Assert.NotNull(context.Format);
4857
Assert.NotNull(context.Image);
4958

50-
return Task.CompletedTask;
59+
return onBeforeSaveAsync.Invoke(context);
5160
};
5261

62+
Func<HttpContext, Task> onPrepareResponseAsync = options.OnPrepareResponseAsync;
63+
5364
options.OnPrepareResponseAsync = context =>
5465
{
5566
Assert.NotNull(context);
5667
Assert.NotNull(context.Response);
5768

58-
return Task.CompletedTask;
69+
return onPrepareResponseAsync.Invoke(context);
5970
};
6071
})
6172
.ClearProviders()

tests/ImageSharp.Web.Tests/TestUtilities/PhysicalFileSystemCacheTestServerFixture.cs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
// Copyright (c) Six Labors.
22
// Licensed under the Apache License, Version 2.0.
33

4+
using System;
45
using System.Threading.Tasks;
56
using Microsoft.AspNetCore.Builder;
7+
using Microsoft.AspNetCore.Http;
68
using Microsoft.Extensions.DependencyInjection;
79
using SixLabors.ImageSharp.Web.DependencyInjection;
10+
using SixLabors.ImageSharp.Web.Middleware;
811
using SixLabors.ImageSharp.Web.Providers;
912
using SixLabors.ImageSharp.Web.Providers.Azure;
1013
using Xunit;
@@ -17,16 +20,20 @@ protected override void ConfigureServices(IServiceCollection services)
1720
{
1821
services.AddImageSharp(options =>
1922
{
23+
Func<ImageCommandContext, Task> onParseCommandsAsync = options.OnParseCommandsAsync;
24+
2025
options.OnParseCommandsAsync = context =>
2126
{
2227
Assert.NotNull(context);
2328
Assert.NotNull(context.Context);
2429
Assert.NotNull(context.Commands);
2530
Assert.NotNull(context.Parser);
2631

27-
return Task.CompletedTask;
32+
return onParseCommandsAsync.Invoke(context);
2833
};
2934

35+
Func<ImageProcessingContext, Task> onProcessedAsync = options.OnProcessedAsync;
36+
3037
options.OnProcessedAsync = context =>
3138
{
3239
Assert.NotNull(context);
@@ -36,24 +43,28 @@ protected override void ConfigureServices(IServiceCollection services)
3643
Assert.NotNull(context.Extension);
3744
Assert.NotNull(context.Stream);
3845

39-
return Task.CompletedTask;
46+
return onProcessedAsync.Invoke(context);
4047
};
4148

49+
Func<FormattedImage, Task> onBeforeSaveAsync = options.OnBeforeSaveAsync;
50+
4251
options.OnBeforeSaveAsync = context =>
4352
{
4453
Assert.NotNull(context);
4554
Assert.NotNull(context.Format);
4655
Assert.NotNull(context.Image);
4756

48-
return Task.CompletedTask;
57+
return onBeforeSaveAsync.Invoke(context);
4958
};
5059

60+
Func<HttpContext, Task> onPrepareResponseAsync = options.OnPrepareResponseAsync;
61+
5162
options.OnPrepareResponseAsync = context =>
5263
{
5364
Assert.NotNull(context);
5465
Assert.NotNull(context.Response);
5566

56-
return Task.CompletedTask;
67+
return onPrepareResponseAsync.Invoke(context);
5768
};
5869
})
5970
.ClearProviders()

0 commit comments

Comments
 (0)