private void ShouldPublishNotification()
        {
            var publishResult = _publisher.Publish("test").Result;

            publishResult.Should().NotBeNull();
            publishResult.IsSuccessful.Should().BeTrue();

            Task.Delay(100).Wait();

            var eventChannelRepository = new EventChannelRepository(_settings.Repository.ProviderAssembly,
                                                                    new ConnectionOptions
            {
                Provider         = _settings.Repository.ProviderType,
                ConnectionString = _settings.Repository.Channel,
            }, _loggerFactory, _diagnostic);

            var eventRepository = new EventRepository(eventChannelRepository, _settings.Repository.ProviderAssembly,
                                                      new ConnectionOptions
            {
                Provider         = _settings.Repository.ProviderType,
                ConnectionString = _settings.Repository.Events
            }, _loggerFactory, _diagnostic);

            var executionResult = eventRepository.SearchAsync(e => e.Channel.Name == _channelName).Result;

            executionResult.Should().NotBeNull();
            executionResult.IsSuccessful.Should().BeTrue();
            executionResult.Result.Should().NotBeNull();
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Post()
        {
            using (var reader = new StreamReader(Request.Body, Encoding.UTF8, true, 1024, true))
            {
                var bodyString = reader.ReadToEnd();

                if (string.IsNullOrEmpty(bodyString))
                {
                    return(BadRequest("Body is empty"));
                }

                var result = await _publisherClientService.Publish(bodyString);

                return(result.IsSuccessful ? (IActionResult)Ok(result.Result) : BadRequest());
            }
        }
Exemplo n.º 3
0
        public void WithStandalone_ShouldPublishNotification()
        {
            var publishResult = _publisher.Publish("test").Result;

            publishResult.Should().NotBeNull();
            publishResult.IsSuccessful.Should().BeTrue();

            Task.Delay(100).Wait();

            var eventRepository = _serviceProvider.GetRequiredService <EventRepository>();

            var executionResult = eventRepository.SearchAsync(e => e.Channel.Name == _channelName).Result;

            executionResult.Should().NotBeNull();
            executionResult.IsSuccessful.Should().BeTrue();
            executionResult.Result.Should().NotBeNull();
        }
Exemplo n.º 4
0
        public void ShouldPublishNotification()
        {
            var channelName = _settings.Value.ApplicationName + "." + _settings.Value.ServiceName;

            var publishResult = _publisher.Publish("test").Result;

            publishResult.Should().NotBeNull();
            publishResult.IsSuccessful.Should().BeTrue();

            Task.Delay(100).Wait();

            var executionResult = _eventRepository.SearchAsync(e => e.Channel.Name == channelName).Result;

            executionResult.Should().NotBeNull();
            executionResult.IsSuccessful.Should().BeTrue();
            executionResult.Result.Should().NotBeNull();
        }