public async Task ShouldLogMessage_WhenSetLogDelate() { var eventBus = new InProcessServiceBus(); var logMsg = ""; var testException = new Exception("Test Exception"); Exception catchedException = null; eventBus.OnLogBusMessage += (logLevel, msg, ex) => { logMsg = msg; catchedException = ex; }; eventBus.AddDynamicSubscription(typeof(TestEventData).Name, eventData => { return(Task.Run(() => { throw testException; })); }); var testEventData = new TestEventData() { Msg = "success" }; await eventBus.Publish(testEventData); Assert.AreNotEqual(0, logMsg.Length); Assert.AreEqual(testException, catchedException); }
public async Task ShouldRaiseException_WhenPublishSetOption() { var eventBus = new InProcessServiceBus(); eventBus.AddDynamicSubscription(typeof(TestEventData).Name, eventData => { return(Task.Run(() => { throw new Exception("Test Exception"); })); }); var testEventData = new TestEventData() { Msg = "success" }; await eventBus.Publish(testEventData, new TriggerOption(false)); }
public async Task DynamicSubscription_ShouldTrigger() { var eventBus = new InProcessServiceBus(); var result = "error"; eventBus.AddDynamicSubscription(typeof(TestEventData).Name, eventData => { return(Task.Run(() => { result = eventData.Msg; })); }); var testEventData = new TestEventData() { Msg = "success" }; await eventBus.Publish(testEventData); Assert.AreEqual(testEventData.Msg, result); }