示例#1
0
        public void Can_send_event()
        {
            // arrange
            MassTransit massTransit = null;

            try
            {
                var container = new Container();
                var handler   = new TestEventHandler();
                container.Register <IEventHandler <TestEvent> >(() => handler);
                var eventRegistry   = new EventHandlerRegistry(container);
                var commandRegistry = new CommandHandlerRegistry(container);
                massTransit = new MassTransit(commandRegistry, eventRegistry, container);
                var eventBus = new EventBus(massTransit);

                // act
                eventBus.Publish(new TestEvent());

                // assert
                Thread.Sleep(TimeSpan.FromSeconds(2));
                Assert.That(handler.NumberOfTimesRan, Is.EqualTo(1));
            }
            finally
            {
                if (massTransit != null)
                {
                    massTransit.Dispose();
                }
            }
        }
示例#2
0
 public void LogFormat(MassTransit.Logging.LogLevel level, string format, params object[] args)
 {
     _log.Log(GetNLogLevel(level), format, args);
 }
示例#3
0
 public void Log(MassTransit.Logging.LogLevel level, LogOutputProvider messageProvider)
 {
     _log.Log(GetNLogLevel(level), ToGenerator(messageProvider));
 }
示例#4
0
 public void Log(MassTransit.Logging.LogLevel level, object obj, Exception exception)
 {
     _log.Log(GetNLogLevel(level), exception, obj?.ToString() ?? "");
 }
示例#5
0
 public void Log(MassTransit.Logging.LogLevel level, object obj)
 {
     _log.Log(GetNLogLevel(level), obj);
 }
示例#6
0
        NLog.LogLevel GetNLogLevel(MassTransit.Logging.LogLevel level)
        {
            if (level == MassTransit.Logging.LogLevel.Fatal)
                return NLog.LogLevel.Fatal;
            if (level == MassTransit.Logging.LogLevel.Error)
                return NLog.LogLevel.Error;
            if (level == MassTransit.Logging.LogLevel.Warn)
                return NLog.LogLevel.Warn;
            if (level == MassTransit.Logging.LogLevel.Info)
                return NLog.LogLevel.Info;
            if (level == MassTransit.Logging.LogLevel.Debug)
                return NLog.LogLevel.Debug;
            if (level == MassTransit.Logging.LogLevel.All)
                return NLog.LogLevel.Trace;

            return NLog.LogLevel.Off;
        }
示例#7
0
 public void Log(MassTransit.Logging.LogLevel level, object obj, Exception exception)
 {
     _log.LogException(GetNLogLevel(level), obj == null ? "" : obj.ToString(), exception);
 }