Пример #1
0
        public void Build()
        {
            // Arrange
            ITopicBuilder builder = Fixture.Create <TopicBuilder>();

            var upperBound = builder.MaxLevel - 1;
            var topicCount = (Fixture.Create <int>() % upperBound) + 1;

            for (var i = 0; i < topicCount; ++i)
            {
                builder = builder.AddTopic(Fixture.Create <string>());
            }

            // Act
            var topic = builder.Build();

            // Assert
            topic.Levels
            .Should()
            .Be(builder.Levels,
                "because the content of the topic should not be altered");
        }
Пример #2
0
 /// <summary>
 /// Default constructor
 /// </summary>
 /// <param name="topicBuilder">State context</param>
 public SubscriberState(ITopicBuilder topicBuilder)
     : base(topicBuilder)
 {
 }
Пример #3
0
 /// <summary>
 /// Default constructor
 /// </summary>
 /// <param name="topicBuilder">State context</param>
 public PublisherState(ITopicBuilder topicBuilder)
     : base(topicBuilder)
 {
 }
Пример #4
0
 /// <summary>
 /// Get an instance of a <see cref="ITopicBuilder"/> in the desired <paramref name="target"/> mode
 /// from an existing builder
 /// </summary>
 /// <param name="builder">Builder to convert</param>
 /// <param name="target">Mode in which converting the target</param>
 /// <returns>A new builder whose consumer is <paramref name="target"/></returns>
 /// <remarks>
 /// If the builder's consumer already is in <paramref name="target"/> mode, this will return a clone
 /// of the provided <paramref name="builder"/>
 /// </remarks>
 private static ITopicBuilder Convert(ITopicBuilder builder, TopicConsumer target)
 => builder.Consumer == target
         ? builder.Clone()
         : new TopicBuilder(builder.TopicCollection, target);
Пример #5
0
 /// <summary>
 /// Get an instance of a <see cref="ITopicBuilder"/> in <see cref="TopicConsumer.Subscriber"/> mode
 /// from an existing builder
 /// </summary>
 /// <param name="builder">Builder to convert</param>
 /// <returns>A new builder whose consumer is <see cref="TopicConsumer.Subscriber"/></returns>
 /// <remarks>
 /// If the builder's consumer already is <see cref="TopicConsumer.Subscriber"/>, this will return a clone
 /// of the provided <paramref name="builder"/>
 /// </remarks>
 public static ITopicBuilder ToSubscriberBuilder(this ITopicBuilder builder)
 => Convert(builder, TopicConsumer.Subscriber);
Пример #6
0
 /// <summary>
 /// Get an instance of a <see cref="ITopicBuilder"/> in <see cref="TopicConsumer.Publisher"/> mode
 /// from an existing builder
 /// </summary>
 /// <param name="builder">Builder to convert</param>
 /// <returns>A new builder whose consumer is <see cref="TopicConsumer.Publisher"/></returns>
 /// <remarks>
 /// If the builder's consumer already is <see cref="TopicConsumer.Publisher"/>, this will return a clone
 /// of the provided <paramref name="builder"/>
 /// </remarks>
 public static ITopicBuilder ToPublisherBuilder(this ITopicBuilder builder)
 => Convert(builder, TopicConsumer.Publisher);
Пример #7
0
 /// <summary>
 /// Default constructor
 /// </summary>
 /// <param name="topicBuilder">Context to be used</param>
 protected BuilderState(ITopicBuilder topicBuilder)
 => TopicBuilder = topicBuilder;