Skip to content

Commit 04e0685

Browse files
committed
[DEVEX-222] Added tests for appends with autoserialization
1 parent a9cfa84 commit 04e0685

File tree

3 files changed

+813
-7
lines changed

3 files changed

+813
-7
lines changed

src/Kurrent.Client/Streams/KurrentClient.Append.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ public Task<IWriteResult> AppendToStreamAsync(
3737

3838
var eventsData = _messageSerializer.Serialize(messages, serializationContext);
3939

40-
return options.StreamRevision.HasValue
40+
return options.ExpectedStreamRevision.HasValue
4141
? AppendToStreamAsync(
4242
streamName,
43-
options.StreamRevision.Value,
43+
options.ExpectedStreamRevision.Value,
4444
eventsData,
4545
options.ConfigureOperationOptions,
4646
options.Deadline,
@@ -49,7 +49,7 @@ public Task<IWriteResult> AppendToStreamAsync(
4949
)
5050
: AppendToStreamAsync(
5151
streamName,
52-
options.StreamState ?? StreamState.Any,
52+
options.ExpectedStreamState ?? StreamState.Any,
5353
eventsData,
5454
options.ConfigureOperationOptions,
5555
options.Deadline,
@@ -562,14 +562,14 @@ public static Task<IWriteResult> AppendToStreamAsync(
562562
// TODO: In the follow up PR merge StreamState and StreamRevision into a one thing
563563
public class AppendToStreamOptions {
564564
/// <summary>
565-
/// The expected <see cref="StreamState"/> of the stream to append to.
565+
/// The expected <see cref="ExpectedStreamState"/> of the stream to append to.
566566
/// </summary>
567-
public StreamState? StreamState { get; set; }
567+
public StreamState? ExpectedStreamState { get; set; }
568568

569569
/// <summary>
570-
/// The expected <see cref="StreamRevision"/> of the stream to append to.
570+
/// The expected <see cref="ExpectedStreamRevision"/> of the stream to append to.
571571
/// </summary>
572-
public StreamRevision? StreamRevision { get; set; }
572+
public StreamRevision? ExpectedStreamRevision { get; set; }
573573

574574
/// <summary>
575575
/// An <see cref="Action{KurrentClientOperationOptions}"/> to configure the operation's options.

test/Kurrent.Client.Tests.Common/Fixtures/KurrentPermanentFixture.Helpers.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System.Runtime.CompilerServices;
22
using System.Text;
33
using EventStore.Client;
4+
using Kurrent.Client.Core.Serialization;
45

56
namespace Kurrent.Client.Tests;
67

@@ -48,6 +49,11 @@ public IEnumerable<EventData> CreateTestEvents(
4849
Enumerable.Range(0, count)
4950
.Select(index => CreateTestEvent(index, type ?? TestEventType, metadata, contentType));
5051

52+
53+
public IEnumerable<Message> CreateTestMessages(int count = 1, object? metadata = null) =>
54+
Enumerable.Range(0, count)
55+
.Select(index => CreateTestMessage(index, metadata));
56+
5157
public EventData CreateTestEvent(
5258
string? type = null, ReadOnlyMemory<byte>? metadata = null, string? contentType = null
5359
) =>
@@ -63,6 +69,13 @@ public IEnumerable<EventData> CreateTestEventsThatThrowsException() {
6369

6470
protected static EventData CreateTestEvent(int index) => CreateTestEvent(index, TestEventType);
6571

72+
protected static Message CreateTestMessage(int index, object? metadata = null) =>
73+
Message.From(
74+
new DummyEvent(index),
75+
metadata,
76+
Uuid.NewUuid()
77+
);
78+
6679
protected static EventData CreateTestEvent(
6780
int index, string type, ReadOnlyMemory<byte>? metadata = null, string? contentType = null
6881
) =>
@@ -104,4 +117,6 @@ public async Task RestartService(TimeSpan delay) {
104117
await Streams.WarmUp();
105118
Log.Information("Service restarted.");
106119
}
120+
121+
public record DummyEvent(int X);
107122
}

0 commit comments

Comments
 (0)