Ejemplo n.º 1
0
        public void JobToBeExecuted()
        {
            var log = new Mock<ILog>();
            var context = new Mock<IJobExecutionContext>();
            var listener = new JobLogger(log.Object);
            var jobDetail = new Mock<IJobDetail>();

            jobDetail.Setup(k => k.JobType)
                   .Returns(typeof(Type));

            context.Setup(k => k.JobDetail)
                   .Returns(jobDetail.Object);

            listener.JobToBeExecuted(context.Object);

            log.Verify(k => k.InfoFormat(It.IsAny<string>(), "Type"));
        }
Ejemplo n.º 2
0
        public void JobThrewException()
        {
            var log = new Mock<ILog>();
            var context = new Mock<IJobExecutionContext>();
            var listener = new JobLogger(log.Object);
            var jobDetail = new Mock<IJobDetail>();

            jobDetail.Setup(k => k.JobType)
                   .Returns(typeof(Type));

            context.Setup(k => k.JobDetail)
                   .Returns(jobDetail.Object);

            var exception = new JobExecutionException("", new Exception("", new Exception("message")));
            
            listener.JobWasExecuted(context.Object, exception);

            log.Verify(k => k.ErrorFormat(It.IsAny<string>(), "Type", "message"));
        }