本文整理汇总了C#中AsyncControllerActionInvoker.BeginInvokeAction方法的典型用法代码示例。如果您正苦于以下问题:C# AsyncControllerActionInvoker.BeginInvokeAction方法的具体用法?C# AsyncControllerActionInvoker.BeginInvokeAction怎么用?C# AsyncControllerActionInvoker.BeginInvokeAction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AsyncControllerActionInvoker
的用法示例。
在下文中一共展示了AsyncControllerActionInvoker.BeginInvokeAction方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InvokeAction_ActionThrowsException_ThreadAbort
public void InvokeAction_ActionThrowsException_ThreadAbort()
{
// Arrange
ControllerContext controllerContext = GetControllerContext();
AsyncControllerActionInvoker invoker = new AsyncControllerActionInvoker();
// Act & assert
Assert.Throws<ThreadAbortException>(
delegate { invoker.BeginInvokeAction(controllerContext, "ActionCallsThreadAbort", null, null); });
}
示例2: InvokeAction_ActionThrowsException_NotHandled
public void InvokeAction_ActionThrowsException_NotHandled()
{
// Arrange
ControllerContext controllerContext = GetControllerContext();
AsyncControllerActionInvoker invoker = new AsyncControllerActionInvoker();
// Act & assert
Assert.Throws<Exception>(
delegate { invoker.BeginInvokeAction(controllerContext, "ActionThrowsExceptionAndIsNotHandled", null, null); },
@"Some exception text.");
}
示例3: InvokeAction_ActionNotFound
public void InvokeAction_ActionNotFound() {
// Arrange
ControllerContext controllerContext = GetControllerContext();
AsyncControllerActionInvoker invoker = new AsyncControllerActionInvoker();
// Act
IAsyncResult asyncResult = invoker.BeginInvokeAction(controllerContext, "ActionNotFound", null, null);
bool retVal = invoker.EndInvokeAction(asyncResult);
// Assert
Assert.IsFalse(retVal);
}
示例4: InvokeAction_AuthorizationFilterShortCircuits
public void InvokeAction_AuthorizationFilterShortCircuits() {
// Arrange
ControllerContext controllerContext = GetControllerContext();
AsyncControllerActionInvoker invoker = new AsyncControllerActionInvoker();
// Act
IAsyncResult asyncResult = invoker.BeginInvokeAction(controllerContext, "AuthorizationFilterShortCircuits", null, null);
bool retVal = invoker.EndInvokeAction(asyncResult);
// Assert
Assert.IsTrue(retVal);
Assert.AreEqual("From authorization filter", ((TestController)controllerContext.Controller).Log);
}
示例5: InvokeAction_ActionThrowsException_Handled
public void InvokeAction_ActionThrowsException_Handled() {
// Arrange
ControllerContext controllerContext = GetControllerContext();
AsyncControllerActionInvoker invoker = new AsyncControllerActionInvoker();
// Act & assert
IAsyncResult asyncResult = invoker.BeginInvokeAction(controllerContext, "ActionThrowsExceptionAndIsHandled", null, null);
Assert.IsNull(((TestController)controllerContext.Controller).Log, "Result filter shouldn't have executed yet.");
bool retVal = invoker.EndInvokeAction(asyncResult);
Assert.IsTrue(retVal);
Assert.AreEqual("From exception filter", ((TestController)controllerContext.Controller).Log);
}
示例6: InvokeAction_NormalAction
public void InvokeAction_NormalAction()
{
// Arrange
ControllerContext controllerContext = GetControllerContext();
AsyncControllerActionInvoker invoker = new AsyncControllerActionInvoker();
// Act
IAsyncResult asyncResult = invoker.BeginInvokeAction(controllerContext, "NormalAction", null, null);
bool retVal = invoker.EndInvokeAction(asyncResult);
// Assert
Assert.True(retVal);
Assert.Equal("From action", ((TestController)controllerContext.Controller).Log);
}
示例7: InvokeAction_ThrowsIfControllerContextIsNull
public void InvokeAction_ThrowsIfControllerContextIsNull()
{
// Arrange
AsyncControllerActionInvoker invoker = new AsyncControllerActionInvoker();
// Act & assert
Assert.ThrowsArgumentNull(
delegate { invoker.BeginInvokeAction(null, "someAction", null, null); }, "controllerContext");
}
示例8: InvokeAction_ThrowsIfActionNameIsNull
public void InvokeAction_ThrowsIfActionNameIsNull()
{
// Arrange
AsyncControllerActionInvoker invoker = new AsyncControllerActionInvoker();
// Act & assert
Assert.ThrowsArgumentNullOrEmpty(
delegate { invoker.BeginInvokeAction(new ControllerContext(), null, null, null); }, "actionName");
}
示例9: InvokeAction_ResultThrowsException_Handled
public void InvokeAction_ResultThrowsException_Handled()
{
// Arrange
ControllerContext controllerContext = GetControllerContext();
AsyncControllerActionInvoker invoker = new AsyncControllerActionInvoker();
// Act & assert
IAsyncResult asyncResult = invoker.BeginInvokeAction(controllerContext, "ResultThrowsExceptionAndIsHandled", null, null);
bool retVal = invoker.EndInvokeAction(asyncResult);
Assert.True(retVal);
Assert.Equal("From exception filter", ((TestController)controllerContext.Controller).Log);
}
示例10: InvokeAction_RequestValidationFails
public void InvokeAction_RequestValidationFails()
{
// Arrange
ControllerContext controllerContext = GetControllerContext(passesRequestValidation: false);
AsyncControllerActionInvoker invoker = new AsyncControllerActionInvoker();
// Act & assert
Assert.Throws<HttpRequestValidationException>(
delegate { invoker.BeginInvokeAction(controllerContext, "NormalAction", null, null); });
}
示例11: InvokeAction_AuthenticationFilterChallenges
public void InvokeAction_AuthenticationFilterChallenges()
{
// Arrange
ControllerContext controllerContext = GetControllerContext();
AsyncControllerActionInvoker invoker = new AsyncControllerActionInvoker();
// Act
IAsyncResult asyncResult = invoker.BeginInvokeAction(controllerContext, "AuthenticationFilterChallenges", null, null);
bool retVal = invoker.EndInvokeAction(asyncResult);
// Assert
Assert.True(retVal);
Assert.Equal("From authentication filter challenge", ((TestController)controllerContext.Controller).Log);
}
示例12: InvokeAction_ThrowsIfActionNameIsEmpty
public void InvokeAction_ThrowsIfActionNameIsEmpty() {
// Arrange
AsyncControllerActionInvoker invoker = new AsyncControllerActionInvoker();
// Act & assert
ExceptionHelper.ExpectArgumentExceptionNullOrEmpty(
delegate {
invoker.BeginInvokeAction(new ControllerContext(), "", null, null);
}, "actionName");
}
示例13: InvokeAction_ResultThrowsException_ThreadAbort
public void InvokeAction_ResultThrowsException_ThreadAbort() {
// Arrange
ControllerContext controllerContext = GetControllerContext();
AsyncControllerActionInvoker invoker = new AsyncControllerActionInvoker();
// Act & assert
IAsyncResult asyncResult = invoker.BeginInvokeAction(controllerContext, "ResultCallsThreadAbort", null, null);
ExceptionHelper.ExpectException<ThreadAbortException>(
delegate {
invoker.EndInvokeAction(asyncResult);
});
}
示例14: InvokeAction_ResultThrowsException_NotHandled
public void InvokeAction_ResultThrowsException_NotHandled() {
// Arrange
ControllerContext controllerContext = GetControllerContext();
AsyncControllerActionInvoker invoker = new AsyncControllerActionInvoker();
// Act & assert
IAsyncResult asyncResult = invoker.BeginInvokeAction(controllerContext, "ResultThrowsExceptionAndIsNotHandled", null, null);
ExceptionHelper.ExpectException<Exception>(
delegate {
invoker.EndInvokeAction(asyncResult);
},
@"Some exception text.");
}
示例15: InvokeAction_RequestValidationFails
public void InvokeAction_RequestValidationFails() {
// Arrange
ControllerContext controllerContext = GetControllerContext(false /* passesRequestValidation */);
AsyncControllerActionInvoker invoker = new AsyncControllerActionInvoker();
// Act & assert
ExceptionHelper.ExpectException<HttpRequestValidationException>(
delegate {
invoker.BeginInvokeAction(controllerContext, "NormalAction", null, null);
});
}