示例#1
0
        public void GetTopics()
        {
            // Arrange
            var topicName = "Publishing.TopicTests.GetTopics";
            _publisher.AddOrUpdateTopic(new Topic { Name = Guid.NewGuid().ToString() });
            _publisher.AddOrUpdateTopic(new Topic { Name = topicName + "1" });
            _publisher.AddOrUpdateTopic(new Topic { Name = topicName + "2" });
            _publisher.AddOrUpdateTopic(new Topic { Name = topicName + "3" });

            // Act
            var topics = _publisher.GetTopics();

            // Assert
            Assert.NotNull(topics);
            Assert.True(topics.Count() >= 4); // Maybe more, which were added by other tests
            Assert.True(topics.Any((t) => t.Name == topicName + "1"));
            Assert.True(topics.Any((t) => t.Name == topicName + "2"));
            Assert.True(topics.Any((t) => t.Name == topicName + "3"));

            // Act
            topics = _publisher.GetTopics(topicName);
            Assert.NotNull(topics);
            Assert.True(topics.Count() == 3);
            Assert.True(topics.Any((t) => t.Name == topicName + "1"));
            Assert.True(topics.Any((t) => t.Name == topicName + "2"));
            Assert.True(topics.Any((t) => t.Name == topicName + "3"));
        }