-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add type argument for stream id * Add tests for querying for events + adjust to genericity * Increment next version
- Loading branch information
Tomas Lycken
authored
Oct 4, 2017
1 parent
b563da1
commit d3bf1ce
Showing
19 changed files
with
126 additions
and
75 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
mode: ContinuousDelivery | ||
next-version: 0.2.0 | ||
next-version: 0.3.0 | ||
branches: | ||
master: | ||
tag: beta | ||
|
44 changes: 44 additions & 0 deletions
44
src/RdbmsEventStore.EntityFramework.Tests/EventStoreTests/QueryEventsTests.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,44 @@ | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using RdbmsEventStore.EntityFramework.Tests.Infrastructure; | ||
using RdbmsEventStore.EntityFramework.Tests.TestData; | ||
using Xunit; | ||
|
||
namespace RdbmsEventStore.EntityFramework.Tests.EventStoreTests | ||
{ | ||
public class QueryEventsTests : EventStoreTestBase<long, string, LongStringEvent> | ||
{ | ||
public QueryEventsTests(EventStoreFixture<long, string, LongStringEvent> fixture, AssemblyInitializerFixture initializer) : base(fixture, initializer) | ||
{ | ||
_dbContext.Events.AddRange(_fixture.EventFactory.Create("stream-1", 0, | ||
new FooEvent{Foo = "Foo"}, | ||
new BarEvent{Bar = "Bar"}, | ||
new FooEvent{Foo = "Baz"})); | ||
_dbContext.Events.AddRange(_fixture.EventFactory.Create("stream-2", 0, | ||
new FooEvent {Foo = "Boo"}, | ||
new BarEvent {Bar = "Far"})); | ||
_dbContext.SaveChanges(); | ||
} | ||
|
||
[Theory] | ||
[InlineData("stream-1", 3)] | ||
[InlineData("stream-2", 2)] | ||
public async Task ReturnsEventsFromCorrectStreamOnly(string streamId, long expectedCount) | ||
{ | ||
var store = _fixture.BuildEventStore(_dbContext); | ||
var events = await store.Events(streamId); | ||
Assert.Equal(expectedCount, events.Count()); | ||
} | ||
|
||
[Theory] | ||
[InlineData("stream-1", 2)] | ||
[InlineData("stream-2", 1)] | ||
public async Task ReturnsEventsAccordingToQuery(string streamId, long expectedCount) | ||
{ | ||
var store = _fixture.BuildEventStore(_dbContext); | ||
var events = await store.Events(streamId, es => es.Where(e => e.Type == "FooEvent")); | ||
Assert.Equal(expectedCount, events.Count()); | ||
} | ||
|
||
} | ||
} |
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
16 changes: 9 additions & 7 deletions
16
src/RdbmsEventStore.EntityFramework.Tests/Infrastructure/EventStoreFixture.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 |
---|---|---|
@@ -1,25 +1,27 @@ | ||
using System; | ||
using RdbmsEventStore.EntityFramework.Tests.TestData; | ||
using RdbmsEventStore.EventRegistry; | ||
|
||
namespace RdbmsEventStore.EntityFramework.Tests.Infrastructure | ||
{ | ||
public class EventStoreFixture | ||
public class EventStoreFixture<TId, TStreamId, TEvent> | ||
where TId : IEquatable<TId> | ||
where TStreamId : IEquatable<TStreamId> | ||
where TEvent : Event<TId, TStreamId>, new() | ||
{ | ||
public EventStoreFixture() | ||
{ | ||
EventRegistry = new AssemblyEventRegistry(typeof(TestEvent), type => type.Name, type => !type.Name.StartsWith("<>")); | ||
EventRegistry = new AssemblyEventRegistry(typeof(TEvent), type => type.Name, type => !type.Name.StartsWith("<>")); | ||
EventSerializer = new DefaultEventSerializer(); | ||
EventFactory = new DefaultEventFactory<Guid, TestEvent>(EventRegistry, EventSerializer); | ||
EventFactory = new DefaultEventFactory<TId, TStreamId, TEvent>(EventRegistry, EventSerializer); | ||
WriteLock = new WriteLock(); | ||
} | ||
|
||
public IEventRegistry EventRegistry { get; } | ||
public IEventSerializer EventSerializer { get; } | ||
public IEventFactory<Guid, TestEvent> EventFactory { get; } | ||
public DefaultEventFactory<TId, TStreamId, TEvent> EventFactory { get; } | ||
public IWriteLock WriteLock { get; } | ||
|
||
public EntityFrameworkEventStore<Guid, EventStoreContext<TestEvent>, TestEvent> BuildEventStore(EventStoreContext<TestEvent> dbContext) | ||
=> new EntityFrameworkEventStore<Guid, EventStoreContext<TestEvent>, TestEvent>(dbContext, EventFactory, WriteLock); | ||
public EntityFrameworkEventStore<TId, TStreamId, EventStoreContext<TEvent>, TEvent> BuildEventStore(EventStoreContext<TEvent> dbContext) | ||
=> new EntityFrameworkEventStore<TId, TStreamId, EventStoreContext<TEvent>, TEvent>(dbContext, EventFactory, WriteLock); | ||
} | ||
} |
16 changes: 8 additions & 8 deletions
16
src/RdbmsEventStore.EntityFramework.Tests/Infrastructure/EventStoreTestBase.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
7 changes: 4 additions & 3 deletions
7
src/RdbmsEventStore.EntityFramework.Tests/Infrastructure/SmokeTest.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
18 changes: 18 additions & 0 deletions
18
src/RdbmsEventStore.EntityFramework.Tests/TestData/EventTypes.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,18 @@ | ||
using System; | ||
|
||
namespace RdbmsEventStore.EntityFramework.Tests.TestData | ||
{ | ||
public class GuidGuidEvent : Event<Guid, Guid> { } | ||
public class LongStringEvent : Event<long, string> { } | ||
public class LongLongEvent : Event<long, long> { } | ||
|
||
public class FooEvent | ||
{ | ||
public string Foo { get; set; } | ||
} | ||
|
||
public class BarEvent | ||
{ | ||
public string Bar { get; set; } | ||
} | ||
} |
12 changes: 0 additions & 12 deletions
12
src/RdbmsEventStore.EntityFramework.Tests/TestData/FooEvent.cs
This file was deleted.
Oops, something went wrong.
6 changes: 0 additions & 6 deletions
6
src/RdbmsEventStore.EntityFramework.Tests/TestData/TestEvent.cs
This file was deleted.
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
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
Oops, something went wrong.