コード例 #1
0
        public void Deliveries_ReturnsAllPostedMessages()
        {
            var message1 = new Amqp.Message();
            var message2 = new Amqp.Message();
            var entity   = new TopicEntity("a", new[] { "b" });

            entity.Post(message1);
            entity.Post(message2);

            entity.Deliveries.ShouldSatisfyAllConditions(
                () => entity.Deliveries.Count.ShouldBe(2),
                () => entity.Deliveries.ShouldContain(a => a.Message == message1),
                () => entity.Deliveries.ShouldContain(a => a.Message == message2)
                );
        }
コード例 #2
0
        public void Post_Throws_WhenMessageNull()
        {
            var entity = new TopicEntity("", new string[0]);

            Should.Throw <ArgumentNullException>(() => entity.Post(null))
            .ParamName.ShouldBe("message");
        }
コード例 #3
0
        public void Post_Throws_WhenObjectDisposed()
        {
            var entity = new TopicEntity("a", new string[0]);

            entity.Dispose();

            Should.Throw <ObjectDisposedException>(() => entity.Post(new Amqp.Message()));
        }
コード例 #4
0
        public void Dispose_CanBeCalledMultipleTimes()
        {
            var entity = new TopicEntity("f", new[] { "g" });

            entity.Post(new Amqp.Message());

            Should.NotThrow(() =>
            {
                entity.Dispose();
                entity.Dispose();
            });
        }
コード例 #5
0
        public void Post_PostsClonesToSubscriptions()
        {
            var message = new Amqp.Message();
            var entity  = new TopicEntity("nm", new[] { "xyz", "007" });

            entity.Post(message);

            entity.ShouldSatisfyAllConditions(
                () => ((IEntity)entity.Subscriptions["xYz"])
                .DeliveryQueue
                .Dequeue(CancellationToken.None)
                .ShouldNotBeSameAs(message),
                () => ((IEntity)entity.Subscriptions["007"])
                .DeliveryQueue
                .Dequeue(CancellationToken.None)
                .ShouldNotBeSameAs(message)
                );
        }