示例#1
0
        public async Task SubscribeMultiple()
        {
            INATS nats = new NATS(_factory, _opts, _log);

            nats.ShouldNotBe(null);
            _server.Received().Sent += Arg.Any <EventHandler <dotnet_sockets.EventArgs <int> > >();
            await nats.Connect();

            nats.Subscribe("a", Substitute.For <Action <string> >());
            nats.Subscribe("b", Substitute.For <Action <string> >());
            nats.Subscribe("a", Substitute.For <Action <string> >());
            _server.Received(2).Send(Arg.Any <string>());
            _server.Received(1).Send(Arg.Is <string>(makeSubscription("a")));
            _server.Received(1).Send(Arg.Is <string>(makeSubscription("b")));
        }
示例#2
0
        public void Unsubscribe()
        {
            INATS nats = new NATS(_factory, _opts, _log);

            nats.ShouldNotBe(null);
            _server.Received().Sent += Arg.Any <EventHandler <dotnet_sockets.EventArgs <int> > >();
            nats.Subscribe("a", Substitute.For <Action <string> >());
            _server.Received(1).Send(Arg.Is <string>(makeSubscription("a")));
            var sid = _sid - 1;

            nats.Unsubscribe("a");
            _server.Received(1).Send(Arg.Is <string>(makeUnsubscription(sid)));
        }