Beispiel #1
0
        public void Setup()
        {
            _messageHandler1     = new TestMessageHandler();
            _messageHandler2     = new TestMessageHandler();
            _topicService        = new TopicService();
            _subscriptionService = new SubscriptionService();
            _messageHelper       = new MessageHelper();

            var configurationHelper = new ConfigurationHelper();

            _projectId = configurationHelper.ProjectId;

            _topic1Id        = $"{configurationHelper.TopicId}-{Guid.NewGuid()}";
            _subscription1Id = $"{configurationHelper.SubscriptionId}-{Guid.NewGuid()}";
            _topic2Id        = $"{configurationHelper.TopicId}-{Guid.NewGuid()}";
            _subscription2Id = $"{configurationHelper.SubscriptionId}-{Guid.NewGuid()}";

            _deadLetterTopicId        = $"{configurationHelper.DeadletterTopicId}-{Guid.NewGuid()}";
            _deadLetterSubscriptionId = $"{configurationHelper.DeadletterSubscriptionId}-{Guid.NewGuid()}";

            _topicService.CreateTopic(_projectId, _topic1Id);
            _topicService.CreateTopic(_projectId, _topic2Id);
            CreateDeadletterTopicAndSubscription();

            _sut1 = new FluentQueueApi();
            _sut2 = new FluentQueueApi();
        }
        public IActionResult CreateTopic(string name, [FromRoute] int id)
        {
            User user = userService.FindUserByID(id);

            topicService.CreateTopic(name, user);
            return(RedirectToAction("home", "Home", user.ID));
        }
        public void Given_A_Topic_Exists_When_I_Call_TopicExists_Then_True_Is_Returned()
        {
            //arrange
            var configurationHelper = new ConfigurationHelper();

            _topicId = $"{configurationHelper.TopicId}-{Guid.NewGuid()}";
            _sut.CreateTopic(_projectId, _topicId);

            //act
            var result = _sut.TopicExists(_projectId, _topicId);

            //assert
            Assert.IsNotNull(result);
            Assert.IsInstanceOf <bool>(result);
            Assert.IsTrue(result);
        }
        public void Given_A_Message_When_I_Call_PublishMessage_Then_The_Message_Is_Published()
        {
            //arrange
            var message = $"Hello, world {Guid.NewGuid()}";

            _topicService.CreateTopic(_projectId, _topicId);
            _subscriptionService.CreateSubscription(_projectId, _topicId, _subscriptionId, _ackTimeoutInSeconds);

            //act
            _sut
            .WithProject(_projectId)
            .WithTopic(_topicId)
            .Publish(message);

            var result = _messageHelper.GetMessage(_projectId, _subscriptionId);

            //assert
            Assert.IsNotNull(result);
            Assert.AreEqual(message, result);
        }
Beispiel #5
0
        public async Task <IActionResult> CreateTopic([FromBody] TopicDto topic)
        {
            var newTopic = await _topicService.CreateTopic(topic.TopicName);

            if (newTopic != null)
            {
                return(Ok(newTopic));
            }
            else
            {
                return(BadRequest());
            }
        }
        public void Setup()
        {
            var configurationHelper = new ConfigurationHelper();

            _projectId = configurationHelper.ProjectId;
            _topicId   = $"{configurationHelper.TopicId}-{Guid.NewGuid()}";

            _subscriptionId      = string.Empty;
            _ackTimeoutInSeconds = 60;

            _topicService = new TopicService();
            _topicService.CreateTopic(_projectId, _topicId);

            _sut = new SubscriptionService();
        }
        public void Setup()
        {
            var configurationHelper = new ConfigurationHelper();

            _projectId      = configurationHelper.ProjectId;
            _topicId        = $"{configurationHelper.TopicId}-{Guid.NewGuid()}";
            _subscriptionId = $"{configurationHelper.SubscriptionId}-{Guid.NewGuid()}";

            _ackTimeoutInSeconds = 60;

            _messageHelper       = new MessageHelper();
            _topicService        = new TopicService();
            _subscriptionService = new SubscriptionService();

            _topicService.CreateTopic(_projectId, _topicId);
            _subscriptionService.CreateSubscription(_projectId, _topicId, _subscriptionId, _ackTimeoutInSeconds);

            _sut = new PublisherService();
        }
 private void CreateDeadletterTopicAndSubscription()
 {
     _topicService.CreateTopic(_projectId, _deadLetterTopicId);
     _subscriptionService.CreateSubscription(_projectId, _deadLetterTopicId, _deadLetterSubscriptionId, 600);
 }
Beispiel #9
0
        public async Task <IActionResult> CreateTopic(CreateTopicViewModel viewModel)
        {
            var createdTopicEntry = await _topicService.CreateTopic(viewModel.Title, viewModel.Message);

            return(RedirectToActionPermanent("Index", new { topicId = createdTopicEntry.Entity.Id }));
        }