-
-
Notifications
You must be signed in to change notification settings - Fork 445
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
32 changed files
with
933 additions
and
64 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
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
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
56 changes: 56 additions & 0 deletions
56
Source/EventFlow.AspNetCore/ServiceProvider/HostedBootstrapper.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,56 @@ | ||
// The MIT License (MIT) | ||
// | ||
// Copyright (c) 2015-2018 Rasmus Mikkelsen | ||
// Copyright (c) 2015-2018 eBay Software Foundation | ||
// https://github.com/eventflow/EventFlow | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
// this software and associated documentation files (the "Software"), to deal in | ||
// the Software without restriction, including without limitation the rights to | ||
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
// the Software, and to permit persons to whom the Software is furnished to do so, | ||
// subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in all | ||
// copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using EventFlow.Configuration.Bootstraps; | ||
using Microsoft.Extensions.Hosting; | ||
|
||
namespace EventFlow.AspNetCore.ServiceProvider | ||
{ | ||
/// <summary> | ||
/// Ensures that the <see cref="Bootstrapper" /> is run in an ASP.NET Core | ||
/// environment when EventFlow is configured into an existing ServiceCollection | ||
/// instance and <see cref="CreateResolver" /> is not used. | ||
/// </summary> | ||
// ReSharper disable once ClassNeverInstantiated.Local | ||
class HostedBootstrapper : IHostedService | ||
{ | ||
private readonly IBootstrapper _bootstrapper; | ||
|
||
public HostedBootstrapper(IBootstrapper bootstrapper) | ||
{ | ||
_bootstrapper = bootstrapper; | ||
} | ||
|
||
public Task StartAsync(CancellationToken cancellationToken) | ||
{ | ||
return _bootstrapper.StartAsync(cancellationToken); | ||
} | ||
|
||
public Task StopAsync(CancellationToken cancellationToken) | ||
{ | ||
return Task.CompletedTask; | ||
} | ||
} | ||
} |
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
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
20 changes: 20 additions & 0 deletions
20
Source/EventFlow.DependencyInjection.Tests/EventFlow.DependencyInjection.Tests.csproj
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,20 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net461</TargetFramework> | ||
<IsPackable>false</IsPackable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="2.0.0" /> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" /> | ||
<PackageReference Include="MSTest.TestAdapter" Version="1.1.18" /> | ||
<PackageReference Include="MSTest.TestFramework" Version="1.1.18" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\EventFlow.DependencyInjection\EventFlow.DependencyInjection.csproj" /> | ||
<ProjectReference Include="..\EventFlow.TestHelpers\EventFlow.TestHelpers.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
62 changes: 62 additions & 0 deletions
62
...yInjection.Tests/IntegrationTests/ServiceCollectionServiceRegistrationIntegrationTests.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,62 @@ | ||
// The MIT License (MIT) | ||
// | ||
// Copyright (c) 2015-2018 Rasmus Mikkelsen | ||
// Copyright (c) 2015-2018 eBay Software Foundation | ||
// https://github.com/eventflow/EventFlow | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
// this software and associated documentation files (the "Software"), to deal in | ||
// the Software without restriction, including without limitation the rights to | ||
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
// the Software, and to permit persons to whom the Software is furnished to do so, | ||
// subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in all | ||
// copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
using System.Threading.Tasks; | ||
using EventFlow.Configuration; | ||
using EventFlow.DependencyInjection.Extensions; | ||
using EventFlow.Extensions; | ||
using EventFlow.TestHelpers; | ||
using EventFlow.TestHelpers.Aggregates.Queries; | ||
using EventFlow.TestHelpers.Suites; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using NUnit.Framework; | ||
|
||
namespace EventFlow.DependencyInjection.Tests.IntegrationTests | ||
{ | ||
[Category(Categories.Integration)] | ||
public class ServiceCollectionServiceRegistrationIntegrationTests : IntegrationTestSuiteForServiceRegistration | ||
{ | ||
protected override IEventFlowOptions Options(IEventFlowOptions eventFlowOptions) | ||
{ | ||
var serviceCollection = new ServiceCollection(); | ||
|
||
serviceCollection.AddScoped<IDbContext, DbContext>(); | ||
|
||
return base.Options(eventFlowOptions | ||
.UseServiceCollection(serviceCollection)) | ||
.AddQueryHandler<DbContextQueryHandler, DbContextQuery, string>(); | ||
} | ||
|
||
protected override IRootResolver CreateRootResolver(IEventFlowOptions eventFlowOptions) | ||
{ | ||
return eventFlowOptions | ||
.CreateResolver(); | ||
} | ||
|
||
[Test] | ||
public override Task QueryingUsesScopedDbContext() | ||
{ | ||
return base.QueryingUsesScopedDbContext(); | ||
} | ||
} | ||
} |
Oops, something went wrong.