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);
        }
示例#2
0
        public void GetAll_ReturnsAllTopics()
        {
            //Arrange
            _topicService.Setup(s => s.GetAllAsync()).Returns(new List <TopicDto>().ToAsyncEnumerable());

            //Act
            var actionResult = _topicController.GetAll();


            //Assert
            actionResult.Result.Should().BeOfType <ActionResult <IEnumerable <TopicDto> > >();
        }
        public void TestGetAllReturnNoContent()
        {
            List <Topic>        listTopic        = new List <Topic>();
            IEnumerable <Topic> iEnumerableTopic = listTopic;

            mockTopicService.Setup(x => x.GetAll()).Returns(iEnumerableTopic);
            var           topicController = new TopicController(mockTopicService.Object);
            IActionResult getAllTopic     = topicController.GetAll();
            var           type            = getAllTopic.GetType();

            Assert.AreEqual(type.Name, "NoContentResult");
        }