|
| 1 | +// ReSharper disable ConditionalAccessQualifierIsNonNullableAccordingToAPIContract |
| 2 | + |
1 | 3 | using EventStore.Client.Diagnostics;
|
2 | 4 | using EventStore.Diagnostics.Tracing;
|
3 | 5 |
|
@@ -171,4 +173,49 @@ async Task Subscribe(IAsyncEnumerator<StreamMessage> internalEnumerator) {
|
171 | 173 | }
|
172 | 174 | }
|
173 | 175 | }
|
| 176 | + |
| 177 | + [Fact] |
| 178 | + [Trait("Category", "Special cases")] |
| 179 | + public async Task should_not_trace_when_event_is_null() { |
| 180 | + var category = Guid.NewGuid().ToString("N"); |
| 181 | + var streamName = category + "-123"; |
| 182 | + |
| 183 | + var seedEvents = Fixture.CreateTestEvents(type: $"{category}-{Fixture.GetStreamName()}").ToArray(); |
| 184 | + await Fixture.Streams.AppendToStreamAsync(streamName, StreamState.NoStream, seedEvents); |
| 185 | + |
| 186 | + await Fixture.Streams.DeleteAsync(streamName, StreamState.StreamExists); |
| 187 | + |
| 188 | + await using var subscription = Fixture.Streams.SubscribeToStream("$ce-" + category, FromStream.Start, resolveLinkTos: true); |
| 189 | + |
| 190 | + await using var enumerator = subscription.Messages.GetAsyncEnumerator(); |
| 191 | + |
| 192 | + Assert.True(await enumerator.MoveNextAsync()); |
| 193 | + |
| 194 | + Assert.IsType<StreamMessage.SubscriptionConfirmation>(enumerator.Current); |
| 195 | + |
| 196 | + await Subscribe().WithTimeout(); |
| 197 | + |
| 198 | + var appendActivities = Fixture |
| 199 | + .GetActivitiesForOperation(TracingConstants.Operations.Append, streamName) |
| 200 | + .ShouldNotBeNull(); |
| 201 | + |
| 202 | + var subscribeActivities = Fixture |
| 203 | + .GetActivitiesForOperation(TracingConstants.Operations.Subscribe, "$ce-" + category) |
| 204 | + .ToArray(); |
| 205 | + |
| 206 | + appendActivities.ShouldHaveSingleItem(); |
| 207 | + subscribeActivities.ShouldBeEmpty(); |
| 208 | + |
| 209 | + return; |
| 210 | + |
| 211 | + async Task Subscribe() { |
| 212 | + while (await enumerator.MoveNextAsync()) { |
| 213 | + if (enumerator.Current is not StreamMessage.Event(var resolvedEvent)) |
| 214 | + continue; |
| 215 | + |
| 216 | + if (resolvedEvent.Event?.EventType is "$metadata") |
| 217 | + return; |
| 218 | + } |
| 219 | + } |
| 220 | + } |
174 | 221 | }
|
0 commit comments