Ejemplo n.º 1
0
        public void JobWasExecuted()
        {
            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);

            context.Setup(k => k.Result)
                   .Returns("ok");

            listener.JobWasExecuted(context.Object, null);

            log.Verify(k => k.InfoFormat(It.IsAny<string>(), "Type", "ok"));
        }
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"));
        }