Ejemplo n.º 1
0
        public void DispatcherTest()
        {
            using (var eventSender = new EventPublisher(_config))
                using (FoutLoggingContext context = new FoutLoggingContext(_options))
                    using (CustomExceptionRepository repo = new CustomExceptionRepository(context))
                        using (FoutLoggingDispatcher dispatcher = new FoutLoggingDispatcher(_config, repo))
                        {
                            var myException = new ExceptionThrownEvent()
                            {
                                ExceptionType = typeof(ArgumentException),
                                GUID          = Guid.NewGuid().ToString(),
                                Message       = "Dit is een TestException",
                                TimeStamp     = DateTime.Now,
                                RoutingKey    = "jomaya.exception.Test"
                            };

                            eventSender.Publish(myException);

                            Thread.Sleep(3000);

                            Assert.IsTrue(context.Exceptions.Count(c => c.ExceptionType == typeof(ArgumentException).ToString()) > 0);

                            var result = context.Exceptions.First(c => c.ExceptionType == typeof(ArgumentException).ToString());

                            Assert.AreEqual("Dit is een TestException", result.Message);
                        }
        }
Ejemplo n.º 2
0
        public void TestCommonExceptionPublisher()
        {
            var errorMessage = "Dit is een TestException";

            var myException = new ArgumentException(errorMessage);

            using (FoutLoggingContext context = new FoutLoggingContext(_options))
                using (CustomExceptionRepository repo = new CustomExceptionRepository(context))
                    using (FoutLoggingDispatcher dispatcher = new FoutLoggingDispatcher(_config, repo))
                    {
                        ExceptionEventPublisher.PublishException(myException, false);

                        Thread.Sleep(10000);

                        Assert.IsTrue(context.Exceptions.Count(c => c.ExceptionType == typeof(ArgumentException).ToString()) > 0);

                        var result = context.Exceptions.First(c => c.ExceptionType == typeof(ArgumentException).ToString());

                        Assert.AreEqual("Dit is een TestException", result.Message);
                    }
        }
Ejemplo n.º 3
0
        private static void initializeEventDispatcher()
        {
            string sqlConnectionString = "server=db;userid=jomaya;password=jomaya;database=jomaya-foutlogging;";

            var optionsBuilder = new DbContextOptionsBuilder <FoutLoggingContext>();

            optionsBuilder.UseMySQL(sqlConnectionString);
            _context = new FoutLoggingContext(optionsBuilder.Options);
            _repo    = new CustomExceptionRepository(_context);

            var config = new EventBusConfig()
            {
                Host      = "rabbitmq",
                Port      = 5672,
                QueueName = "jomaya.foutlogging.queue"
            };

            var publisher = new EventPublisher(config);

            _dispatcher = new FoutLoggingDispatcher(config, _repo);
        }
Ejemplo n.º 4
0
 public FoutLoggingDispatcher(EventBusConfig config, CustomExceptionRepository repo) : base(config)
 {
     _repo = repo;
 }