public async Task SubscriptionHandlesShouldHaveIdentity() { var stream = Silo.AddStreamProbe <ChatMessage>(Guid.Empty, null); await Silo.CreateGrainAsync <Listener>(1); var handlers = await stream.GetAllSubscriptionHandles(); handlers.Count.Should().Be(1); stream.Subscribed.Should().Be(1); foreach (var handle in handlers) { handle.ProviderName.Should().Be("Default"); handle.HandleId.Should().NotBeEmpty(); handle.StreamIdentity.Should().NotBeNull(); handle.StreamIdentity.Namespace.Should().BeNull(); } await handlers[0].UnsubscribeAsync(); handlers.Count.Should().Be(1); stream.Subscribed.Should().Be(0); }
public void GrainIsSubscribed() { var stream = Silo.AddStreamProbe <ChatMessage>(Guid.Empty, null); Silo.CreateGrain <Listener>(1); stream.Subscribed.Should().Be(1); }
public async Task GrainIsSubscribed() { var stream = Silo.AddStreamProbe <ChatMessage>(Guid.Empty, null); await Silo.CreateGrainAsync <Listener>(1); stream.Subscribed.Should().Be(1); }
public async Task GrainReceives() { var stream = Silo.AddStreamProbe <ChatMessage>(Guid.Empty, null); var grain = Silo.CreateGrain <Listener>(1); await stream.OnNextAsync(new ChatMessage("Ding")); (await grain.ReceivedCount()).Should().Be(1); }
public void IncorrectProbeNamespace() { var chatty = Silo.CreateGrain <Chatty>(4); Silo.AddStreamProbe <ChatMessage>(Guid.Empty, "Wrong"); const string msg = "Hello Chat"; chatty.Invoking(p => p.SendChat(msg).Wait()).ShouldNotThrow(); }
public void IncorrectProbeId() { var chatty = Silo.CreateGrain <Chatty>(4); Silo.AddStreamProbe <ChatMessage>(Guid.NewGuid(), null); const string msg = "Hello Chat"; chatty.Invoking(p => p.SendChat(msg).Wait()).ShouldNotThrow(); }
public async Task IncorrectProbeNamespace() { var chatty = await Silo.CreateGrainAsync <Chatty>(4); Silo.AddStreamProbe <ChatMessage>(Guid.Empty, "Wrong"); const string msg = "Hello Chat"; chatty.Invoking(p => p.SendChat(msg).Wait()).ShouldThrow <Exception>(); }
public async Task IncorrectProbeId() { var chatty = await Silo.CreateGrainAsync <Chatty>(4); Silo.AddStreamProbe <ChatMessage>(Guid.NewGuid(), null); const string msg = "Hello Chat"; chatty.Invoking(p => p.SendChat(msg).Wait()).Should().Throw <Exception>(); }
public async Task IncorrectVerifyMessage() { var chatty = Silo.CreateGrain <Chatty>(4); var stream = Silo.AddStreamProbe <ChatMessage>(Guid.Empty, null); const string msg = "Hello Chat"; await chatty.SendChat(msg); stream.Invoking(s => s.VerifySend(m => m.Msg == "This is not right")).ShouldThrow <Exception>(); }
public async Task GrainSentMessages() { var chatty = Silo.CreateGrain <Chatty>(4); var stream = Silo.AddStreamProbe <ChatMessage>(Guid.Empty, null); const string msg = "Hello Chat"; await chatty.SendChat(msg); stream.Sends.Should().Be(1); stream.VerifySend(m => m.Msg == msg); }
public async Task OnGameCreationWhenPlayerIIJoins_Should_StreamEvent() { var gameId = Guid.NewGuid(); var sut = BuildSut(gameId); var stream = Silo.AddStreamProbe <PlayerTookSeatII> (gameId, nameof(PlayerTookSeatII)); var playerId = Guid.NewGuid(); var playerSeat = Silo.CreateGrain <SeatII> (id: gameId); await playerSeat.JoinGame(playerId); stream.Sends.Should().Be(1); stream.VerifySend(x => x.PlayerId == playerId); }
public async Task GrainGetAllSubscriptionHandles() { var stream = Silo.AddStreamProbe <ChatMessage>(Guid.Empty, null); await Silo.CreateGrainAsync <Listener>(1); var handlers = await stream.GetAllSubscriptionHandles(); handlers.Count.Should().Be(1); stream.Subscribed.Should().Be(1); await handlers[0].UnsubscribeAsync(); handlers.Count.Should().Be(1); stream.Subscribed.Should().Be(0); }
public async Task GrainSentBatchMessages() { var chatty = await Silo.CreateGrainAsync <Chatty>(4); var stream = Silo.AddStreamProbe <ChatMessage>(Guid.Empty, null); var msgs = new[] { "Hello Chat", "Goodbye Chat" }; await chatty.SendChatBatch(msgs); stream.Sends.Should().Be((uint)msgs.Length); foreach (var msg in msgs) { stream.VerifySend(m => m.Msg == msg); } }
public PersistantStreamNotWithinGrainStateTests() { _stateWithoutHandle = new PersistentListenerStateWithoutHandle(); _persistentState = new Mock <IPersistentState <PersistentListenerStateWithoutHandle> >(); _persistentState.SetupGet(o => o.State).Returns(_stateWithoutHandle); var mockMapper = new Mock <IAttributeToFactoryMapper <PersistentStateAttribute> >(); mockMapper.Setup(o => o.GetFactory(It.IsAny <ParameterInfo>(), It.IsAny <PersistentStateAttribute>())) .Returns(context => _persistentState.Object); Silo.AddService(mockMapper.Object); _stream = Silo.AddStreamProbe <ChatMessage>(Guid.Empty, null, "Default"); }
public async Task GrainSentBatchMessagesHandlesException() { var chatty = await Silo.CreateGrainAsync <Chatty>(4); var stream = Silo.AddStreamProbe <ChatMessage>(Guid.Empty, null); var mockObserver = new Mock <IAsyncObserver <ChatMessage> >(); mockObserver.Setup(o => o.OnNextAsync(It.IsAny <ChatMessage>(), It.IsAny <StreamSequenceToken>())) .Throws <Exception>(); await stream.SubscribeAsync(mockObserver.Object); var msgs = new[] { "Hello Chat", "Goodbye Chat" }; await Assert.ThrowsAsync <AggregateException>(() => chatty.SendChatBatch(msgs)); stream.Sends.Should().Be((uint)msgs.Length); foreach (var msg in msgs) { stream.VerifySend(m => m.Msg == msg); } }