Exemplo n.º 1
0
 public void Should_not_print_warning_if_finalization_takes_more_than_1_and_half_second_but_is_called_manually()
 {
     _subject.OnBeforeFinish += () => Thread.Sleep(1550);
     using (var console = new TraceInterceptor())
     {
         _subject.Finished();
         Assert.That(console.GetCapturedText(), Is.Empty);
     }
 }
Exemplo n.º 2
0
 public void Should_not_print_warning_if_finalization_takes_less_than_1_and_half_second()
 {
     _subject.OnBeforeFinish += () => Thread.Sleep(1450);
     using (var console = new TraceInterceptor())
     {
         _subject = null;
         GC.Collect(GC.MaxGeneration);
         GC.WaitForPendingFinalizers();
         Assert.That(console.GetCapturedText(), Is.Not.StringContaining("WARNING: Please consider"));
     }
 }
Exemplo n.º 3
0
 public void Should_trace_error_if_exception_is_thrown_during_finalization()
 {
     _subject.OnBeforeFinish += () => { throw new NotImplementedException("abc"); };
     using (var console = new TraceInterceptor())
     {
         _subject = null;
         GC.Collect(GC.MaxGeneration);
         GC.WaitForPendingFinalizers();
         Assert.That(console.GetCapturedText(), Is.StringContaining("Summary aggregation failed: System.NotImplementedException: abc"));
     }
 }
Exemplo n.º 4
0
 public void Should_trace_warning_if_finalization_takes_longer_than_1_and_half_second()
 {
     _subject.OnBeforeFinish += () => Thread.Sleep(1550);
     using (var console = new TraceInterceptor())
     {
         _subject = null;
         GC.Collect(GC.MaxGeneration);
         GC.WaitForPendingFinalizers();
         Assert.That(console.GetCapturedText(), Is.StringContaining("WARNING: Please consider to call FeatureCoordinator.Instance.Finished() manually, otherwise if execution time reach 2 seconds, .NET framework will kill aggregation process."));
     }
 }
        public void MethodCall_MustUseInterceptorsInCorrectSequence()
        {
            var interceptionCallLog = new List<IDynamicInterceptor>();
            var interceptor1 = new TraceInterceptor(interceptionCallLog, "1");
            var interceptor2 = new TraceInterceptor(interceptionCallLog, "2");
            var interceptor3 = new TraceInterceptor(interceptionCallLog, "3");

            this.Container.RegisterInterfaceProxy<IProxy>(
                new Intercept(interceptor1),
                new Intercept(interceptor2),
                new Intercept(interceptor3));

            this.Container.Resolve<IProxy>().Foo();

            interceptionCallLog.Should()
                           .ContainInOrder(interceptor1, interceptor2, interceptor3)
                           .And.HaveCount(3);
        }
Exemplo n.º 6
0
        public void MethodCall_MustUseInterceptorsInCorrectSequence()
        {
            var interceptionCallLog = new List <IDynamicInterceptor>();
            var interceptor1        = new TraceInterceptor(interceptionCallLog, "1");
            var interceptor2        = new TraceInterceptor(interceptionCallLog, "2");
            var interceptor3        = new TraceInterceptor(interceptionCallLog, "3");

            this.Container.RegisterInterfaceProxy <IProxy>(
                new Intercept(interceptor1),
                new Intercept(interceptor2),
                new Intercept(interceptor3));

            this.Container.Resolve <IProxy>().Foo();

            interceptionCallLog.Should()
            .ContainInOrder(interceptor1, interceptor2, interceptor3)
            .And.HaveCount(3);
        }
        public void MustUseInterceptorsInCorrectOrder()
        {
            var interceptionCallLog = new List <IDynamicInterceptor>();
            var interceptor1        = new TraceInterceptor(interceptionCallLog, "1");
            var interceptor2        = new TraceInterceptor(interceptionCallLog, "2");
            var interceptor3        = new TraceInterceptor(interceptionCallLog, "3");

            this.Container.RegisterType <InterceptedTarget, InterceptedTarget>(
                new Intercept(interceptor1),
                new Intercept(interceptor2),
                new Intercept(interceptor3));

            var proxy = this.Container.Resolve <InterceptedTarget>();

            proxy.Bar();

            interceptionCallLog.Should()
            .ContainInOrder(interceptor1, interceptor2, interceptor3)
            .And.HaveCount(3);
        }
        public void MustUseInterceptorsInCorrectOrder()
        {
            var interceptionCallLog = new List<IDynamicInterceptor>();
            var interceptor1 = new TraceInterceptor(interceptionCallLog, "1");
            var interceptor2 = new TraceInterceptor(interceptionCallLog, "2");
            var interceptor3 = new TraceInterceptor(interceptionCallLog, "3");

            this.Container.RegisterType<InterceptedTarget, InterceptedTarget>(
                new Intercept(interceptor1),
                new Intercept(interceptor2),
                new Intercept(interceptor3));

            var proxy = this.Container.Resolve<InterceptedTarget>();

            proxy.Bar();

            interceptionCallLog.Should()
                .ContainInOrder(interceptor1, interceptor2, interceptor3)
                .And.HaveCount(3);
        }
        public void MethodCall_MustUseInterceptorsInCorrectSequence()
        {
            var interceptionCallLog = new List<IDynamicInterceptor>();
            var interceptor1 = new TraceInterceptor(interceptionCallLog, "1");
            var interceptor2 = new TraceInterceptor(interceptionCallLog, "2");
            var interceptor3 = new TraceInterceptor(interceptionCallLog, "3");

            using (var kernel = new StandardKernel())
            {
                kernel.Bind<IProxy>().ToProxy(x => x
                        .By(interceptor1, 10)
                        .By(interceptor2, 5)
                        .By(interceptor3, 15));

                var proxy = kernel.Get<IProxy>();

                proxy.Foo();
            }

            interceptionCallLog.Should()
                           .ContainInOrder(interceptor2, interceptor1, interceptor3)
                           .And.HaveCount(3);
        }
        public void MustUseInterceptorsInCorrectOrder()
        {
            var interceptionCallLog = new List<IDynamicInterceptor>();
            var interceptor1 = new TraceInterceptor(interceptionCallLog, "1");
            var interceptor2 = new TraceInterceptor(interceptionCallLog, "2");
            var interceptor3 = new TraceInterceptor(interceptionCallLog, "3");

            using (var kernel = new StandardKernel())
            {
                kernel.Bind<InterceptedTarget>().ToSelf()
                    .Intercept(x => x
                        .By(interceptor1, 10)
                        .By(interceptor2, 5)
                        .By(interceptor3, 15));

                var proxy = kernel.Get<InterceptedTarget>();

                proxy.Bar();

                interceptionCallLog.Should()
                    .ContainInOrder(interceptor2, interceptor1, interceptor3)
                    .And.HaveCount(3);
            }
        }