public async void Sent() { var settingsMock = RabbitMqSettingsTest.GetSettingsMock(); var queueBuilderMock = new Mock <IQueueBuilder>(); var busControllerMock = new Mock <IBusControl>(); var sendEndpointMock = new Mock <ISendEndpoint>(); busControllerMock .Setup(x => x.Publish(It.IsAny <DummyClass>(), It.IsAny <CancellationToken>())) .Returns(Task.FromResult(sendEndpointMock.Object)); var sender = new RabbitMqSender(busControllerMock.Object, queueBuilderMock.Object, settingsMock.Object); await sender.Send(new DummyClass()); // Verify that the MassTransit calls are executed busControllerMock.Verify(x => x.Publish(It.IsAny <DummyClass>(), It.IsAny <CancellationToken>()), Times.Once()); }
public void Run(CancellationToken ct) { while (!ct.IsCancellationRequested) { try { foreach (var job in _jobService.GetAll(true)) { try { if (!job.NeedRun()) { continue; } job.CheckPointTime = DateTime.UtcNow;//Injection time //Send to Message Queue //Com.Gmlan.Scheduler.TaskExecutor, Com.Gmlan.Scheduler will be responsible for all task execution //So this project won't rely on any Hook assemblies _rabbitMqSender.Send( new MessageBody( "Com.Gmlan.Scheduler.JobExecutor, Com.Gmlan.Scheduler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", "Consume", job)); } catch (System.Exception ex) { _log.Error(ex.Message, ex); } } } catch (Exception ex) { _log.Error(ex.Message, ex);//For Database connection issue, log to file appender } Thread.Sleep(1000 * 60);//should sleep for 1 min, 10*60 for test only } }