public void CreateControllerReleaser_InvokesIControllerFactory_IfItIsNotDefaultControllerFactory()
        {
            // Arrange
            var controller = new object();
            var factory    = new Mock <IControllerFactory>();

            factory.Setup(f => f.ReleaseController(It.IsAny <ControllerContext>(), controller))
            .Verifiable();
            var provider = new ControllerFactoryProvider(
                Mock.Of <IControllerActivatorProvider>(),
                factory.Object,
                Enumerable.Empty <IControllerPropertyActivator>());
            var descriptor = new ControllerActionDescriptor
            {
                ControllerTypeInfo = typeof(object).GetTypeInfo(),
            };

            // Act
            var releaser = provider.CreateControllerReleaser(descriptor);

            releaser(new ControllerContext(), controller);

            // Assert
            factory.Verify();
        }
        public void CreateControllerReleaser_ReturnsReleaser()
        {
            // Arrange
            var controller = new object();
            var factory    = new DefaultControllerFactory(
                Mock.Of <IControllerActivator>(),
                Enumerable.Empty <IControllerPropertyActivator>());
            Action <ControllerContext, object> expected = (_, __) => { };
            var activatorProvider = new Mock <IControllerActivatorProvider>();

            activatorProvider.Setup(p => p.CreateReleaser(It.IsAny <ControllerActionDescriptor>()))
            .Returns(expected)
            .Verifiable();
            var provider = new ControllerFactoryProvider(
                activatorProvider.Object,
                factory,
                Enumerable.Empty <IControllerPropertyActivator>());
            var descriptor = new ControllerActionDescriptor
            {
                ControllerTypeInfo = typeof(object).GetTypeInfo(),
            };

            // Act
            var actual = provider.CreateControllerReleaser(descriptor);

            // Assert
            Assert.Same(expected, actual);
            activatorProvider.Verify();
        }