private async Task And_a_topic()
        {
            _topicController = new TopicController(
                _serviceProvider.GetService <ITopicDomainService>(),
                _serviceProvider.GetService <ITopicRepository>(),
                _serviceProvider.GetService <ICapabilityRepository>(),
                _serviceProvider.GetService <IKafkaJanitorRestClient>()
                );


            var result = await _topicController.AddTopicToCapability(
                _capability.Id.ToString(),
                new TopicInput { Name = "the topic of the future", Description = "The way topics should be", Partitions = 2, KafkaClusterId = _cluster.Id.ToString(), DryRun = false });

            // Creation of a Topic as it is now needs to be refactored to avoid having to put a random delay/sleep here.
            Thread.Sleep(2000);
            var removeThisAllTopics = await _topicController.GetAll();

            var actionResult = await _topicController
                               .GetAllByCapability(_capability.Id.ToString());

            var okResult = actionResult as OkObjectResult;

            var topicsCollection = (Topic[])okResult.Value
                                   .GetType()
                                   .GetProperty("Items")
                                   .GetValue(okResult.Value);

            var topics = topicsCollection.Any() ? topicsCollection : null;


            Assert.Single(topics);
        }
        private async Task And_a_topic()
        {
            _topicController = new TopicController(
                _serviceProvider.GetService <ITopicDomainService>(),
                _serviceProvider.GetService <ITopicRepository>(),
                _serviceProvider.GetService <ICapabilityRepository>(),
                _serviceProvider.GetService <IKafkaJanitorRestClient>()
                );


            await _topicController.AddTopicToCapability(
                _capability.Id.ToString(),
                new TopicInput { Name = "the topic of the future", Description = "The way topics should be", Partitions = 2 });

            var topics = await DoUntilResultOr5Sec(async() =>
            {
                var actionResult = await _topicController
                                   .GetAllByCapability(_capability.Id.ToString());

                var okResult = actionResult as OkObjectResult;

                var topics = (Topic[])okResult.Value
                             .GetType()
                             .GetProperty("Items")
                             .GetValue(okResult.Value);

                return(topics.Any() ? topics : null);
            });


            Assert.Single(topics);
        }
예제 #3
0
        private async Task Then_it_wont_be_found_under_capability_topics()
        {
            var actionResult = await _topicController.GetAllByCapability(_capability.Id.ToString());

            var okResult = actionResult as OkObjectResult;

            var topics = (Topic[])okResult.Value
                         .GetType()
                         .GetProperty("Items")
                         .GetValue(okResult.Value);


            Assert.Empty(topics);
        }
예제 #4
0
        private async Task Then_it_can_be_found_under_capability_topics()
        {
            var topics = await DoUntilResultOr5Sec(async() =>
            {
                var actionResult = await _topicController
                                   .GetAllByCapability(_capability.Id.ToString());

                var okResult = actionResult as OkObjectResult;

                var topics = (Topic[])okResult.Value
                             .GetType()
                             .GetProperty("Items")
                             .GetValue(okResult.Value);

                return(topics.Any() ? topics : null);
            });


            Assert.Single(topics);
            Assert.StartsWith(
                "pub.",
                topics.Single().Name
                );
        }