-
-
Notifications
You must be signed in to change notification settings - Fork 448
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
44 changed files
with
1,658 additions
and
319 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
Source/EventFlow.MongoDB.Tests/EventFlow.MongoDB.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,17 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<Import Project="../Common.props" /> | ||
<PropertyGroup> | ||
<TargetFrameworks>net461</TargetFrameworks> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="MongoDB.Driver" Version="2.7.2" /> | ||
<PackageReference Include="Mongo2Go" Version="2.2.8" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\EventFlow.MongoDB\EventFlow.MongoDB.csproj" /> | ||
<ProjectReference Include="..\EventFlow.TestHelpers\EventFlow.TestHelpers.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
41 changes: 41 additions & 0 deletions
41
Source/EventFlow.MongoDB.Tests/IntegrationTests/EventStores/MongoDbEventStoreTests.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,41 @@ | ||
using System; | ||
using EventFlow.Configuration; | ||
using EventFlow.TestHelpers; | ||
using EventFlow.TestHelpers.Suites; | ||
using EventFlow.Extensions; | ||
using EventFlow.MongoDB.EventStore; | ||
using EventFlow.MongoDB.Extensions; | ||
using EventFlow.MongoDB.ValueObjects; | ||
using NUnit.Framework; | ||
using Mongo2Go; | ||
using MongoDB.Driver; | ||
|
||
namespace EventFlow.MongoDB.Tests.IntegrationTests.EventStores | ||
{ | ||
[Category(Categories.Integration)] | ||
[TestFixture] | ||
[NUnit.Framework.Timeout(30000)] | ||
public class MongoDbEventStoreTests : TestSuiteForEventStore | ||
{ | ||
private MongoDbRunner _runner; | ||
|
||
protected override IRootResolver CreateRootResolver(IEventFlowOptions eventFlowOptions) | ||
{ | ||
_runner = MongoDbRunner.Start(); | ||
var resolver = eventFlowOptions | ||
.ConfigureMongoDb(_runner.ConnectionString, "eventflow") | ||
.UseMongoDbEventStore() | ||
.CreateResolver(); | ||
var eventPersistenceInitializer = resolver.Resolve<IMongoDbEventPersistenceInitializer>(); | ||
eventPersistenceInitializer.Initialize(); | ||
|
||
return resolver; | ||
} | ||
|
||
[TearDown] | ||
public void TearDown() | ||
{ | ||
_runner.Dispose(); | ||
} | ||
} | ||
} |
74 changes: 74 additions & 0 deletions
74
Source/EventFlow.MongoDB.Tests/IntegrationTests/ReadStores/MongoDbReadModelStoreTests.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,74 @@ | ||
// 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; | ||
using EventFlow.Configuration; | ||
using EventFlow.Extensions; | ||
using EventFlow.MongoDB.Extensions; | ||
using EventFlow.MongoDB.Tests.IntegrationTests.ReadStores.QueryHandlers; | ||
using EventFlow.MongoDB.Tests.IntegrationTests.ReadStores.ReadModels; | ||
using EventFlow.MongoDB.ValueObjects; | ||
using EventFlow.TestHelpers; | ||
using EventFlow.TestHelpers.Aggregates.Entities; | ||
using EventFlow.TestHelpers.Suites; | ||
using Mongo2Go; | ||
using MongoDB.Driver; | ||
using NUnit.Framework; | ||
|
||
namespace EventFlow.MongoDB.Tests.IntegrationTests.ReadStores | ||
{ | ||
[Category(Categories.Integration)] | ||
[TestFixture] | ||
[NUnit.Framework.Timeout(30000)] | ||
public class MongoDbReadModelStoreTests : TestSuiteForReadModelStore | ||
{ | ||
protected override Type ReadModelType { get; } = typeof(MongoDbThingyReadModel); | ||
|
||
private MongoDbRunner _runner; | ||
|
||
protected override IRootResolver CreateRootResolver(IEventFlowOptions eventFlowOptions) | ||
{ | ||
_runner = MongoDbRunner.Start(); | ||
|
||
var resolver = eventFlowOptions | ||
.RegisterServices(sr => { sr.RegisterType(typeof(ThingyMessageLocator)); }) | ||
.ConfigureMongoDb(_runner.ConnectionString, "eventflow") | ||
.UseMongoDbReadModel<MongoDbThingyReadModel>() | ||
.UseMongoDbReadModel<MongoDbThingyMessageReadModel, ThingyMessageLocator>() | ||
.AddQueryHandlers( | ||
typeof(MongoDbThingyGetQueryHandler), | ||
typeof(MongoDbThingyGetVersionQueryHandler), | ||
typeof(MongoDbThingyGetMessagesQueryHandler)) | ||
.CreateResolver(); | ||
|
||
return resolver; | ||
} | ||
|
||
|
||
[TearDown] | ||
public void TearDown() | ||
{ | ||
_runner.Dispose(); | ||
} | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
...B.Tests/IntegrationTests/ReadStores/QueryHandlers/MongoDbThingyGetMessagesQueryHandler.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,55 @@ | ||
// 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.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using EventFlow.MongoDB.ReadStores; | ||
using EventFlow.MongoDB.Tests.IntegrationTests.ReadStores.ReadModels; | ||
using EventFlow.Queries; | ||
using EventFlow.TestHelpers.Aggregates.Entities; | ||
using EventFlow.TestHelpers.Aggregates.Queries; | ||
using MongoDB.Driver; | ||
|
||
namespace EventFlow.MongoDB.Tests.IntegrationTests.ReadStores.QueryHandlers | ||
{ | ||
public class MongoDbThingyGetMessagesQueryHandler : IQueryHandler<ThingyGetMessagesQuery, IReadOnlyCollection<ThingyMessage>> | ||
{ | ||
private readonly IMongoDbReadModelStore<MongoDbThingyMessageReadModel> _readStore; | ||
|
||
public MongoDbThingyGetMessagesQueryHandler( | ||
IMongoDbReadModelStore<MongoDbThingyMessageReadModel> mongeReadStore) | ||
{ | ||
_readStore = mongeReadStore; | ||
} | ||
|
||
public async Task<IReadOnlyCollection<ThingyMessage>> ExecuteQueryAsync(ThingyGetMessagesQuery query, CancellationToken cancellationToken) | ||
{ | ||
var thingyId = query.ThingyId.ToString(); | ||
var asyncCursor = await _readStore.FindAsync(f => string.Equals(f.ThingyId, thingyId), cancellationToken: cancellationToken).ConfigureAwait(false); | ||
var thingyMessageReadModels = await asyncCursor.ToListAsync(cancellationToken: cancellationToken).ConfigureAwait(false); | ||
return thingyMessageReadModels.Select(b => b.ToThingyMessage()).ToList(); | ||
} | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
...w.MongoDB.Tests/IntegrationTests/ReadStores/QueryHandlers/MongoDbThingyGetQueryHandler.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,53 @@ | ||
// 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.Linq; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using EventFlow.MongoDB.ReadStores; | ||
using EventFlow.MongoDB.Tests.IntegrationTests.ReadStores.ReadModels; | ||
using EventFlow.Queries; | ||
using EventFlow.TestHelpers.Aggregates; | ||
using EventFlow.TestHelpers.Aggregates.Queries; | ||
using MongoDB.Driver; | ||
|
||
namespace EventFlow.MongoDB.Tests.IntegrationTests.ReadStores.QueryHandlers | ||
{ | ||
public class MongoDbThingyGetQueryHandler : IQueryHandler<ThingyGetQuery, Thingy> | ||
{ | ||
private readonly IMongoDbReadModelStore<MongoDbThingyReadModel> _readStore; | ||
public MongoDbThingyGetQueryHandler( | ||
IMongoDbReadModelStore<MongoDbThingyReadModel> mongeReadStore) | ||
{ | ||
_readStore = mongeReadStore; | ||
} | ||
|
||
public async Task<Thingy> ExecuteQueryAsync(ThingyGetQuery query, CancellationToken cancellationToken) | ||
{ | ||
var thingyId = query.ThingyId.ToString(); | ||
var asyncCursor = await _readStore.FindAsync(f => string.Equals(f.Id, thingyId), cancellationToken: cancellationToken).ConfigureAwait(false); | ||
var thingyReadModel = await asyncCursor.FirstOrDefaultAsync(cancellationToken: cancellationToken).ConfigureAwait(false); | ||
return thingyReadModel?.ToThingy(); | ||
} | ||
} | ||
} |
Oops, something went wrong.