public void AddTopic_OnBlankTopic() { // Arrange ITopicBuilder builder = new TopicBuilder(TopicConsumer.Subscriber); // Act Action appendingEmptyTopic = () => builder.AddTopic(string.Empty); // Assert appendingEmptyTopic.Should() .Throw <EmptyTopicException>("because an empty topic is not a valid one to be added"); }
public void AddTopic_OnTopicSeparator() { // Arrange ITopicBuilder builder = new TopicBuilder(TopicConsumer.Subscriber); // Act Action appendingTopic = () => builder.AddTopic( Mqtt.Topic.Separator.ToString()); // Assert appendingTopic.Should() .Throw <InvalidTopicException>("because the topic separator is not a valid topic to be appended"); }
public void AddTopic_OnMultiLevelWildcard() { // Arrange ITopicBuilder builder = new TopicBuilder(TopicConsumer.Publisher); // Act Action addSingleLevelWildcard = () => builder = builder.AddTopic( Mqtt.Wildcard.MultiLevel.ToString()); // Assert addSingleLevelWildcard.Should() .Throw <IllegalTopicConstructionException>( "because a topic used on PUBLISH mode cannot use wildcard"); }
public void AddTopic_OnValidTopic() { // Arrange var addCount = Fixture.Create <int>(); ITopicBuilder builder = new TopicBuilder(addCount + 1, TopicConsumer.Subscriber); // Act for (var i = 0; i < addCount; ++i) { builder = builder.AddTopic(Fixture.Create <string>()); } // Assert builder.Levels .Should() .Be(addCount, "because there should be as many levels as topics added"); }
public void AddTopic_OnSingleLevelWildcard() { // Arrange ITopicBuilder builder = new TopicBuilder(TopicConsumer.Subscriber); // Act builder = builder.AddTopic( Mqtt.Wildcard.SingleLevel.ToString()); // Assert builder.Levels .Should() .Be(1, "because the wildcard consist of one level"); builder.IsAppendingAllowed .Should() .BeTrue("because a topic appending is allowed after a single-level wildcard"); }
public void AddTopic_OnMultiLevelWildcard() { // Arrange ITopicBuilder builder = new TopicBuilder(TopicConsumer.Subscriber); // Act builder = builder.AddTopic( Mqtt.Wildcard.MultiLevel.ToString()); // Assert builder.Levels .Should() .Be(1, "because the wildcard consist of one level"); builder.IsAppendingAllowed .Should() .BeFalse("because no addition should be allowed after a multi-level wildcard"); }