Beispiel #1
0
        public void ToPublisherBuilder_FromSubscriberWithoutWildcards()
        {
            // Arrange
            var topics = Fixture.Create <List <string> >();

            var builder = new TopicBuilder(topics.Count + 1, TopicConsumer.Subscriber)
                          .AddTopics(topics);

            // Act
            var publisherBuilder = builder.ToPublisherBuilder();

            // Assert
            publisherBuilder.Levels
            .Should()
            .Be(builder.Levels,
                "because the content of the builder should remain the same");

            publisherBuilder.TopicCollection.ToArray()
            .Should()
            .Contain(builder.TopicCollection.ToArray(),
                     "because the content of the builder should remain the same");

            publisherBuilder.Consumer
            .Should()
            .Be(TopicConsumer.Publisher,
                "because the consumer should have changed for the converted builder");
        }
Beispiel #2
0
        public void ToPublisherBuilder_FromSubscriberWithWildcards()
        {
            // Arrange
            var topics = Fixture.Create <List <string> >();

            topics.Add(Mqtt.Wildcard.SingleLevel.ToString());
            topics.AddRange(Fixture.Create <List <string> >());

            var builder = new TopicBuilder(topics.Count + 1, TopicConsumer.Subscriber)
                          .AddTopics(topics);

            // Act
            Action convertingSubscriberWithTopicsToPublisher = () =>
                                                               _ = builder.ToPublisherBuilder();

            // Assert
            convertingSubscriberWithTopicsToPublisher.Should()
            .Throw <IllegalTopicConstructionException>(
                "because converting a topic should not bypass topic construction rules");
        }