Exemplo n.º 1
0
        public void TestIntercept()
        {
            var mockLoggingService = new Mock <ILoggingService>();
            var args = new MethodExecutionArgs(null, Arguments.Empty);

            ObjectFactory.Initialize(x => x.For <ILoggingService>().Use(mockLoggingService.Object));
            var loggingAspect = new MyLoggingAspect();

            loggingAspect.RuntimeInitialize(null);

            loggingAspect.OnEntry(args);
            loggingAspect.OnSuccess(args);

            mockLoggingService.Verify(x => x.Write("Log start"));
            mockLoggingService.Verify(x => x.Write("Log end"));
        }
Exemplo n.º 2
0
        public void TestIntercept()
        {
            var mockLoggingService = new Mock<ILoggingService>();
            var args = new MethodExecutionArgs(null, Arguments.Empty);

            ObjectFactory.Initialize(x => x.For<ILoggingService>().Use(mockLoggingService.Object));
            var loggingAspect = new MyLoggingAspect();
            loggingAspect.RuntimeInitialize(null);

            loggingAspect.OnEntry(args);
            loggingAspect.OnSuccess(args);

            mockLoggingService.Verify(x => x.Write("Log start"));
            mockLoggingService.Verify(x => x.Write("Log end"));
        }