public void FindActionReturnsNullIfNoActionFound() {
            // Arrange
            Type controllerType = typeof(MyController);
            ReflectedAsyncControllerDescriptor cd = new ReflectedAsyncControllerDescriptor(controllerType);

            // Act
            ActionDescriptor ad = cd.FindAction(new Mock<ControllerContext>().Object, "NonExistent");

            // Assert
            Assert.IsNull(ad);
        }
        public void FindActionThrowsIfActionNameIsEmpty() {
            // Arrange
            Type controllerType = typeof(MyController);
            ReflectedAsyncControllerDescriptor cd = new ReflectedAsyncControllerDescriptor(controllerType);

            // Act & assert
            ExceptionHelper.ExpectArgumentExceptionNullOrEmpty(
                delegate {
                    cd.FindAction(new Mock<ControllerContext>().Object, "");
                }, "actionName");
        }
        public void FindActionReturnsActionDescriptorIfFound() {
            // Arrange
            Type controllerType = typeof(MyController);
            MethodInfo setupMethod = controllerType.GetMethod("Foo");
            MethodInfo completionMethod = controllerType.GetMethod("FooCompleted");
            ReflectedAsyncControllerDescriptor cd = new ReflectedAsyncControllerDescriptor(controllerType);

            // Act
            ActionDescriptor ad = cd.FindAction(new Mock<ControllerContext>().Object, "NewName");

            // Assert
            Assert.AreEqual("NewName", ad.ActionName);
            Assert.IsInstanceOfType(ad, typeof(ReflectedEventPatternActionDescriptor));
            ReflectedEventPatternActionDescriptor castAd = (ReflectedEventPatternActionDescriptor)ad;

            Assert.AreSame(setupMethod, castAd.SetupMethod, "SetupMethod pointed to wrong method.");
            Assert.AreSame(completionMethod, castAd.CompletionMethod, "CompletionMethod pointed to wrong method.");
            Assert.AreSame(cd, ad.ControllerDescriptor, "Controller did not point back to correct descriptor.");
        }
        public void FindActionThrowsIfControllerContextIsNull() {
            // Arrange
            Type controllerType = typeof(MyController);
            ReflectedAsyncControllerDescriptor cd = new ReflectedAsyncControllerDescriptor(controllerType);

            // Act & assert
            ExceptionHelper.ExpectArgumentNullException(
                delegate {
                    cd.FindAction(null, "someName");
                }, "controllerContext");
        }