public void OnActionExecuting_NotActionAuthorizationRequiredNoPcs_ThrowsInvalidOperationException() { var fakeController = BuildFakeMemberRegistrationController(); var fakeActionParameters = ActionExecutingContextHelper.FakeActionParameters(false, A.Dummy <Guid>()); ActionExecutingContext context = new ActionExecutingContext(); context.ActionParameters = fakeActionParameters; context.ActionDescriptor = ActionExecutingContextHelper.FakeActionDescriptorWithActionName("TestAction"); Assert.Throws(typeof(InvalidOperationException), () => fakeController.InvokeOnActionExecuting(context)); }
public void OnActionExecuting_ActionAuthorizationRequired_DoesNotCheckPcsId() { var fakeController = BuildFakeMemberRegistrationController(); var fakeActionParameters = ActionExecutingContextHelper.FakeActionParameters(); var fakeActionDescriptor = ActionExecutingContextHelper.FakeActionDescriptorWithActionName("AuthorisationRequired"); ActionExecutingContext context = new ActionExecutingContext(); context.ActionParameters = fakeActionParameters; context.ActionDescriptor = fakeActionDescriptor; fakeController.InvokeOnActionExecuting(context); A.CallTo(() => fakeActionDescriptor.ActionName).MustHaveHappened(Repeated.Exactly.Once); object dummyObject; A.CallTo(() => fakeActionParameters.TryGetValue(A <string> ._, out dummyObject)).MustNotHaveHappened(); }
public void OnActionExecuting_NotActionAuthorizationRequiredApprovedPcs_ResultsToNoRedirection() { var fakeController = BuildFakeMemberRegistrationController(); var fakeActionParameters = ActionExecutingContextHelper.FakeActionParameters(true, A.Dummy <Guid>()); ActionExecutingContext context = new ActionExecutingContext(); context.ActionParameters = fakeActionParameters; context.ActionDescriptor = ActionExecutingContextHelper.FakeActionDescriptorWithActionName("TestAction"); A.CallTo(() => weeeClient.SendAsync(A <string> ._, A <GetSchemeStatus> ._)) .Returns(SchemeStatus.Approved); fakeController.InvokeOnActionExecuting(context); A.CallTo(() => weeeClient.SendAsync(A <string> ._, A <GetSchemeStatus> ._)) .MustHaveHappened(); Assert.Null(context.Result); }
public void OnActionExecuting_NotActionAuthorizationRequiredNotApprovedPcs_ResultsToAuthorizationRequired() { var pcsId = Guid.NewGuid(); var fakeController = BuildFakeMemberRegistrationController(); var fakeActionParameters = ActionExecutingContextHelper.FakeActionParameters(true, pcsId); ActionExecutingContext context = new ActionExecutingContext(); context.ActionParameters = fakeActionParameters; context.ActionDescriptor = ActionExecutingContextHelper.FakeActionDescriptorWithActionName("TestAction"); A.CallTo(() => weeeClient.SendAsync(A <string> ._, A <GetSchemeStatus> ._)) .Returns(SchemeStatus.Pending); fakeController.InvokeOnActionExecuting(context); var redirect = (RedirectToRouteResult)context.Result; Assert.Equal("AuthorisationRequired", redirect.RouteValues["action"]); Assert.Equal(pcsId, redirect.RouteValues["pcsId"]); }