Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
rogeralsing committed Dec 10, 2023
1 parent fc5119f commit e96602c
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/Proto.Actor.Tests/EventStreamTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Proto.Mailbox;
using Xunit;
Expand All @@ -17,6 +18,9 @@ public async Task EventStream_CanSubscribeToSpecificEventTypes()

eventStream.Subscribe<string>(theString => received = theString);
eventStream.Publish("hello");

await Task.Delay(1000);

Assert.Equal("hello", received);
}

Expand All @@ -32,6 +36,9 @@ public async Task EventStream_CanSubscribeToAllEventTypes()
eventStream.Publish("hello");
eventStream.Publish(1);
eventStream.Publish(true);

await Task.Delay(1000);

Assert.Equal(3, receivedEvents.Count);
}

Expand All @@ -46,6 +53,9 @@ public async Task EventStream_CanUnsubscribeFromEvents()
eventStream.Publish("first message");
subscription.Unsubscribe();
eventStream.Publish("second message");

await Task.Delay(1000);

Assert.Single(receivedEvents);
}

Expand All @@ -59,6 +69,9 @@ public async Task EventStream_OnlyReceiveSubscribedToEventTypes()
var eventsReceived = new List<object>();
eventStream.Subscribe<int>(@event => eventsReceived.Add(@event));
eventStream.Publish("not an int");

await Task.Delay(1000);

Assert.Empty(eventsReceived);
}

Expand All @@ -79,5 +92,6 @@ public async Task EventStream_CanSubscribeToSpecificEventTypes_Async()
);

eventStream.Publish("hello");
await Task.Delay(1000);
}
}

0 comments on commit e96602c

Please sign in to comment.