public void ConstructorSetsProperties() {
            // Arrange
            string actionName = "SomeAction";
            ControllerDescriptor cd = new Mock<ControllerDescriptor>().Object;

            // Act
            ReflectedAsyncPatternActionDescriptor ad = new ReflectedAsyncPatternActionDescriptor(_validBeginMethod, _validEndMethod, actionName, cd);

            // Assert
            Assert.AreEqual(_validBeginMethod, ad.BeginMethod);
            Assert.AreEqual(_validEndMethod, ad.EndMethod);
            Assert.AreEqual(actionName, ad.ActionName);
            Assert.AreEqual(cd, ad.ControllerDescriptor);
        }
        public void IsDefined() {
            // Arrange
            ReflectedAsyncPatternActionDescriptor ad = new ReflectedAsyncPatternActionDescriptor(_validBeginMethod, _validEndMethod, "SomeAction", new Mock<ControllerDescriptor>().Object);

            // Act
            bool isDefined = ad.IsDefined(typeof(AuthorizeAttribute), true /* inherit */);

            // Assert
            Assert.IsTrue(isDefined);
        }
        public void GetParametersWrapsParameterInfos() {
            // Arrange
            ParameterInfo pInfo = typeof(MyController).GetMethod("BeginFooValid").GetParameters()[0];
            ReflectedAsyncPatternActionDescriptor ad = new ReflectedAsyncPatternActionDescriptor(_validBeginMethod, _validEndMethod, "SomeAction", new Mock<ControllerDescriptor>().Object);

            // Act
            ParameterDescriptor[] pDescsFirstCall = ad.GetParameters();
            ParameterDescriptor[] pDescsSecondCall = ad.GetParameters();

            // Assert
            Assert.AreNotSame(pDescsFirstCall, pDescsSecondCall, "GetParameters() should return a new array on each invocation.");
            Assert.IsTrue(pDescsFirstCall.SequenceEqual(pDescsSecondCall), "Array elements were not equal.");
            Assert.AreEqual(1, pDescsFirstCall.Length);

            ReflectedParameterDescriptor pDesc = pDescsFirstCall[0] as ReflectedParameterDescriptor;

            Assert.IsNotNull(pDesc, "Parameter 0 should have been of type ReflectedParameterDescriptor.");
            Assert.AreSame(ad, pDesc.ActionDescriptor, "Parameter 0 Action did not match.");
            Assert.AreSame(pInfo, pDesc.ParameterInfo, "Parameter 0 ParameterInfo did not match.");
        }
        public void GetCustomAttributesFilterByType() {
            // Should not match attributes on the EndFoo() method, only the BeginFoo() method

            // Arrange
            ReflectedAsyncPatternActionDescriptor ad = new ReflectedAsyncPatternActionDescriptor(_validBeginMethod, _validEndMethod, "SomeAction", new Mock<ControllerDescriptor>().Object);

            // Act
            object[] attributes = ad.GetCustomAttributes(typeof(OutputCacheAttribute), true /* inherit */);

            // Assert
            Assert.AreEqual(0, attributes.Length);
        }
        public void GetCustomAttributes() {
            // Arrange
            ReflectedAsyncPatternActionDescriptor ad = new ReflectedAsyncPatternActionDescriptor(_validBeginMethod, _validEndMethod, "SomeAction", new Mock<ControllerDescriptor>().Object);

            // Act
            object[] attributes = ad.GetCustomAttributes(true /* inherit */);

            // Assert
            Assert.AreEqual(1, attributes.Length);
            Assert.IsInstanceOfType(attributes[0], typeof(AuthorizeAttribute));
        }