-
-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Query collection to remove. Fix #62 * Lock Azure Storage creation * Use Empty try...catch
- Loading branch information
1 parent
75fd113
commit 5d381f0
Showing
6 changed files
with
159 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
tests/ImageSharp.Web.Tests/DependencyInjection/MockImageProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using Microsoft.AspNetCore.Http; | ||
using SixLabors.ImageSharp.Web.Providers; | ||
using SixLabors.ImageSharp.Web.Resolvers; | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace SixLabors.ImageSharp.Web.Tests.DependencyInjection | ||
{ | ||
public class MockImageProvider : IImageProvider | ||
{ | ||
public Func<HttpContext, bool> Match { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } | ||
|
||
public Task<IImageResolver> GetAsync(HttpContext context) => throw new NotImplementedException(); | ||
|
||
public bool IsValidRequest(HttpContext context) => throw new NotImplementedException(); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
tests/ImageSharp.Web.Tests/DependencyInjection/MockWebProcessor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using Microsoft.Extensions.Logging; | ||
using SixLabors.ImageSharp.Web.Processors; | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace SixLabors.ImageSharp.Web.Tests.DependencyInjection | ||
{ | ||
public class MockWebProcessor : IImageWebProcessor | ||
{ | ||
public IEnumerable<string> Commands => throw new NotImplementedException(); | ||
|
||
public FormattedImage Process(FormattedImage image, ILogger logger, IDictionary<string, string> commands) => throw new NotImplementedException(); | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
tests/ImageSharp.Web.Tests/DependencyInjection/ServiceRegistrationExtensionsTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using Microsoft.AspNetCore.TestHost; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using SixLabors.ImageSharp.Web.DependencyInjection; | ||
using System; | ||
using Xunit; | ||
|
||
namespace SixLabors.ImageSharp.Web.Tests.DependencyInjection | ||
{ | ||
public class ServiceRegistrationExtensionsTests | ||
{ | ||
[Fact] | ||
public void CanAddRemoveImageProviders() | ||
{ | ||
void RemoveServices(IServiceCollection services) | ||
{ | ||
var builder = services.AddImageSharp() | ||
.AddProvider<MockImageProvider>(); | ||
|
||
Assert.Contains(services, x => x.ImplementationType == typeof(MockImageProvider)); | ||
|
||
builder.RemoveProvider<MockImageProvider>(); | ||
|
||
Assert.DoesNotContain(services, x => x.ImplementationType == typeof(MockImageProvider)); | ||
} | ||
|
||
using (TestServer server = ImageSharpTestServer.Create(ImageSharpTestServer.DefaultConfig, RemoveServices)) | ||
{ | ||
} | ||
} | ||
|
||
[Fact] | ||
public void CanAddRemoveImageProcessors() | ||
{ | ||
void RemoveServices(IServiceCollection services) | ||
{ | ||
var builder = services.AddImageSharp() | ||
.AddProcessor<MockWebProcessor>(); | ||
|
||
Assert.Contains(services, x => x.ImplementationType == typeof(MockWebProcessor)); | ||
|
||
builder.RemoveProcessor<MockWebProcessor>(); | ||
|
||
Assert.DoesNotContain(services, x => x.ImplementationType == typeof(MockWebProcessor)); | ||
} | ||
|
||
using (TestServer server = ImageSharpTestServer.Create(ImageSharpTestServer.DefaultConfig, RemoveServices)) | ||
{ | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters