-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DEVEX-222] Added overloads of Append methods that take regular events
They currently use dummy serialisation
- Loading branch information
1 parent
f0e35bd
commit 33e2f5a
Showing
2 changed files
with
154 additions
and
22 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
42 changes: 42 additions & 0 deletions
42
test/Kurrent.Client.Tests/Streams/Serialization/SerializationTests.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,42 @@ | ||
using EventStore.Client; | ||
|
||
namespace Kurrent.Client.Tests.Streams.Serialization; | ||
|
||
[Trait("Category", "Target:Streams")] | ||
[Trait("Category", "Operation:Append")] | ||
public class SerializationTests : KurrentPermanentTests<KurrentPermanentFixture> { | ||
public SerializationTests(ITestOutputHelper output, KurrentPermanentFixture fixture) : base(output, fixture) { | ||
Fixture.ClientSettings.Serialization = KurrentClientSerializationSettings.Default(); | ||
} | ||
|
||
[RetryFact] | ||
public async Task appends_and_reads_with_default_serialization() { | ||
var stream = $"{Fixture.GetStreamName()}_{StreamState.Any}"; | ||
|
||
var writeResult = await Fixture.Streams.AppendToStreamAsync( | ||
stream, | ||
StreamState.Any, | ||
GenerateEvents() | ||
); | ||
|
||
Assert.Equal(new(0), writeResult.NextExpectedStreamRevision); | ||
|
||
var count = await Fixture.Streams.ReadStreamAsync(Direction.Forwards, stream, StreamPosition.Start, 2) | ||
.CountAsync(); | ||
|
||
Assert.Equal(1, count); | ||
} | ||
|
||
private IEnumerable<UserRegistered> GenerateEvents(int count = 1) => | ||
Enumerable.Range(0, count) | ||
.Select( | ||
_ => new UserRegistered( | ||
Guid.NewGuid(), | ||
new Address(Guid.NewGuid().ToString(), Guid.NewGuid().GetHashCode()) | ||
) | ||
); | ||
|
||
public record Address(string Street, int Number); | ||
|
||
public record UserRegistered(Guid UserId, Address Address); | ||
} |