Ejemplo n.º 1
0
        public void DefaultControllerFactory_ReleasesNonIDisposableController()
        {
            // Arrange
            var factory    = new DefaultControllerFactory(Mock.Of <IControllerActivator>());
            var controller = new object();

            // Act + Assert (does not throw)
            factory.ReleaseController(controller);
        }
Ejemplo n.º 2
0
        public void DefaultControllerFactory_ReleasesNonIDisposableController()
        {
            // Arrange
            var factory = new DefaultControllerFactory(
                Mock.Of <IServiceProvider>(),
                Mock.Of <ITypeActivator>(),
                Mock.Of <IControllerActivator>());

            var controller = new Object();

            // Act + Assert
            Assert.DoesNotThrow(() => factory.ReleaseController(controller));
        }
Ejemplo n.º 3
0
        public void DefaultControllerFactory_DisposesIDisposableController()
        {
            // Arrange
            var factory    = new DefaultControllerFactory(Mock.Of <IControllerActivator>());
            var controller = new MyController();

            // Act + Assert
            Assert.False(controller.Disposed);

            factory.ReleaseController(controller);

            Assert.True(controller.Disposed);
        }
Ejemplo n.º 4
0
        public void DefaultControllerFactory_ReleasesNonIDisposableController()
        {
            // Arrange
            var factory = new DefaultControllerFactory(
                Mock.Of<IServiceProvider>(),
                Mock.Of<ITypeActivator>(),
                Mock.Of<IControllerActivator>());

            var controller = new Object();

            // Act + Assert
            Assert.DoesNotThrow(() => factory.ReleaseController(controller));
        }
Ejemplo n.º 5
0
        public void DisposeControllerFactoryWithDisposableController()
        {
            // Arrange
            IControllerFactory    factory        = new DefaultControllerFactory();
            Mock <ControllerBase> mockController = new Mock <ControllerBase>();
            Mock <IDisposable>    mockDisposable = mockController.As <IDisposable>();

            mockDisposable.Setup(d => d.Dispose()).Verifiable();

            // Act
            factory.ReleaseController(mockController.Object);

            // Assert
            mockDisposable.Verify();
        }
Ejemplo n.º 6
0
        public void ReleaseController(IController controller)
        {
            //get spring context
            IApplicationContext ctx = ContextRegistry.GetContext();

            if (!ctx.ContainsObject(controller.GetType().Name))
            {
                if (defalutf == null)
                {
                    defalutf = new DefaultControllerFactory();
                }

                defalutf.ReleaseController(controller);
            }
        }
Ejemplo n.º 7
0
        public void DefaultControllerFactory_DisposesIDisposableController()
        {
            // Arrange
            var factory = new DefaultControllerFactory(
                Mock.Of<IServiceProvider>(),
                Mock.Of<ITypeActivator>(),
                Mock.Of<IControllerActivator>());

            var controller = new MyController();

            // Act + Assert
            Assert.False(controller.Disposed);

            factory.ReleaseController(controller);

            Assert.True(controller.Disposed);
        }
        public void DisposeControllerFactoryWithDisposableController()
        {
            // Arrange
            IControllerFactory factory = new DefaultControllerFactory();
            Mock<ControllerBase> mockController = new Mock<ControllerBase>();
            Mock<IDisposable> mockDisposable = mockController.As<IDisposable>();
            mockDisposable.Setup(d => d.Dispose()).Verifiable();

            // Act
            factory.ReleaseController(mockController.Object);

            // Assert
            mockDisposable.Verify();
        }
Ejemplo n.º 9
0
 public void ReleaseController(IController controller)
 {
     Default.ReleaseController(controller);
 }
Ejemplo n.º 10
0
 public void ReleaseController(ControllerContext context, object controller) => defaultControllerFactory.ReleaseController(context, controller);
 public void ReleaseController(IController controller)
 {
     defaultControllerFactory.ReleaseController(controller);
 }
        public void DefaultControllerFactory_ReleasesNonIDisposableController()
        {
            // Arrange
            var factory = new DefaultControllerFactory(Mock.Of<IControllerActivator>());
            var controller = new object();

            // Act + Assert (does not throw)
            factory.ReleaseController(controller);
        }