public void ComposesActionDescriptor_WithValueResultConverter_WhenActionReturnsValue(
            Type actionType, Type expectedConverterType, IFixture fixture, ValueActionFilterAttribute filter)
        {
            // Fixture setup
            fixture.Freeze<Mock<HttpActionDescriptor>>()
                .SetupGet(des => des.ReturnType)
                .Returns(actionType);

            var context = fixture.Create<HttpActionContext>();
            // Exercise system
            filter.OnActionExecuting(context);
            // Verify outcome
            context.ActionDescriptor.ResultConverter.Should().BeOfType(expectedConverterType);
        }
        public void ComposesActionDescriptor_WithValueResultConverter_WhenActionReturnsValue(
            Type actionType, Type expectedConverterType, IFixture fixture, ValueActionFilterAttribute filter)
        {
            // Fixture setup
            fixture.Freeze <Mock <HttpActionDescriptor> >()
            .SetupGet(des => des.ReturnType)
            .Returns(actionType);

            var context = fixture.Create <HttpActionContext>();

            // Exercise system
            filter.OnActionExecuting(context);
            // Verify outcome
            context.ActionDescriptor.ResultConverter.Should().BeOfType(expectedConverterType);
        }
        public void DoesNotChangeDescriptor_WhenActionDoesNotReturnValue(
            Type actionType, IFixture fixture, ValueActionFilterAttribute filter)
        {
            // Fixture setup
            fixture.Freeze<Mock<HttpActionDescriptor>>()
                .SetupGet(des => des.ReturnType)
                .Returns(actionType);

            var context = fixture.Create<HttpActionContext>();
            var initialDescriptor = context.ActionDescriptor;
            // Exercise system
            filter.OnActionExecuting(context);
            // Verify outcome
            context.ActionDescriptor.Should().BeSameAs(initialDescriptor);
        }
        public void DoesNotChangeDescriptor_WhenActionDoesNotReturnValue(
            Type actionType, IFixture fixture, ValueActionFilterAttribute filter)
        {
            // Fixture setup
            fixture.Freeze <Mock <HttpActionDescriptor> >()
            .SetupGet(des => des.ReturnType)
            .Returns(actionType);

            var context           = fixture.Create <HttpActionContext>();
            var initialDescriptor = context.ActionDescriptor;

            // Exercise system
            filter.OnActionExecuting(context);
            // Verify outcome
            context.ActionDescriptor.Should().BeSameAs(initialDescriptor);
        }
        public void WrapsActionDescriptor_WithDelegatingActionDescriptor_WhenActionReturnsValue(
            IFixture fixture, ValueActionFilterAttribute filter)
        {
            // FIxture  setup
            var initialDescriptor = fixture.Freeze<HttpActionDescriptor>();

            Mock.Get(initialDescriptor)
                .SetupGet(des => des.ReturnType)
                .Returns(typeof (Model));

            var context = fixture.Create<HttpActionContext>();
            // Exercise system
            filter.OnActionExecuting(context);
            // Verify outcome
            var descriptor = context.ActionDescriptor;

            descriptor.Should().BeOfType<DelegatingActionDescriptor>();
            descriptor.As<DelegatingActionDescriptor>()
                .InnerActionDescriptor.Should().Be(initialDescriptor);
        }
        public void WrapsActionDescriptor_WithDelegatingActionDescriptor_WhenActionReturnsValue(
            IFixture fixture, ValueActionFilterAttribute filter)
        {
            // FIxture  setup
            var initialDescriptor = fixture.Freeze <HttpActionDescriptor>();

            Mock.Get(initialDescriptor)
            .SetupGet(des => des.ReturnType)
            .Returns(typeof(Model));

            var context = fixture.Create <HttpActionContext>();

            // Exercise system
            filter.OnActionExecuting(context);
            // Verify outcome
            var descriptor = context.ActionDescriptor;

            descriptor.Should().BeOfType <DelegatingActionDescriptor>();
            descriptor.As <DelegatingActionDescriptor>()
            .InnerActionDescriptor.Should().Be(initialDescriptor);
        }
 public void ThrowsWhenActionContextIsNull(ValueActionFilterAttribute filter)
 {
     // Exercise system and verify outcome
     Assert.Throws <ArgumentNullException>(() => filter.OnActionExecuting(null));
 }
 public void IsActionFilterAttribute(ValueActionFilterAttribute filter)
 {
     // Exercise system and verify outcome
     filter.Should().BeAssignableTo <ActionFilterAttribute>();
 }
 public void ThrowsWhenActionContextIsNull(ValueActionFilterAttribute filter)
 {
     // Exercise system and verify outcome
     Assert.Throws<ArgumentNullException>(() => filter.OnActionExecuting(null));
 }
 public void IsActionFilterAttribute(ValueActionFilterAttribute filter)
 {
     // Exercise system and verify outcome
     filter.Should().BeAssignableTo<ActionFilterAttribute>();
 }