Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Enumerator Exception Being Overridden w/ DeadlineExceeded #100

Merged
merged 1 commit into from
Jan 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/EventStore.Client.Streams/EventStoreClient.Append.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@ await call.RequestStream.WriteAsync(new AppendReq {
}
}).ConfigureAwait(false);
}

await call.RequestStream.CompleteAsync().ConfigureAwait(false);
} finally {
await call.RequestStream.CompleteAsync().ConfigureAwait(false);

var response = await call.ResponseAsync.ConfigureAwait(false);

if (response.Success != null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Xunit;

namespace EventStore.Client {
public class append_to_stream_when_events_enumerator_throws
: IClassFixture<append_to_stream_when_events_enumerator_throws.Fixture> {
private readonly Fixture _fixture;

public append_to_stream_when_events_enumerator_throws(Fixture fixture) {
_fixture = fixture;
}

[Fact]
public void throws_the_exception() {
Assert.IsType<EnumerationFailedException>(_fixture.CaughtException);
}

[Fact]
public async Task the_write_does_not_succeed() {
var result = _fixture.Client.ReadStreamAsync(Direction.Forwards, _fixture.StreamName, StreamPosition.Start);
Assert.Equal(ReadState.StreamNotFound, await result.ReadState);
}

private class EnumerationFailedException : Exception {
}

public class Fixture : EventStoreClientFixture {
public string StreamName { get; }

public Fixture() {
StreamName = GetStreamName("stream");
}

public Exception CaughtException { get; private set; }

protected override async Task Given() {
try {
await Client.AppendToStreamAsync(StreamName, StreamRevision.None, Events());
} catch (Exception ex) {
CaughtException = ex;
}

IEnumerable<EventData> Events() {
var i = 0;
foreach (var e in CreateTestEvents(5)) {
if (i++ % 3 == 0) {
throw new EnumerationFailedException();
}

yield return e;
}
}
}

protected override Task When() => Task.CompletedTask;
}
}
}