public void ExecuteSubFunction_SenderRequiresRegistrationForPostBack() { Control senderMock = MockRepository.StrictMultiMock <Control> (typeof(IPostBackDataHandler)); senderMock.Stub(stub => stub.UniqueID).Return(c_senderUniqueID).Repeat.Any(); PostBackCollection.Remove(c_senderUniqueID); IExecutionState executionState = CreateExecutionStateForDoRepost(senderMock, WxePermaUrlOptions.Null); using (MockRepository.Ordered()) { using (MockRepository.Unordered()) { _pageMock.Expect(mock => mock.GetPostBackCollection()).Return(PostBackCollection); } _pageMock.Expect(mock => mock.RegisterRequiresPostBack(senderMock)); _pageMock.Expect(mock => mock.SaveAllState()); ExecutionStateContextMock.Expect(mock => mock.SetExecutionState(Arg <ExecutingSubFunctionWithoutPermaUrlState> .Is.NotNull)) .WhenCalled(invocation => CheckExecutionState((ExecutingSubFunctionWithoutPermaUrlState)invocation.Arguments[0])); } MockRepository.ReplayAll(); executionState.ExecuteSubFunction(WxeContext); MockRepository.VerifyAll(); }
public void ExecuteSubFunction_WithPermaUrl_ReturnToCaller_WithCallerUrlParameters_GoesToRedirectingToSubFunction () { WxePermaUrlOptions permaUrlOptions = new WxePermaUrlOptions(); IExecutionState executionState = CreateExecutionState (permaUrlOptions, new WxeReturnOptions (new NameValueCollection { { "Key", "Value" } })); ExecutionStateContextMock.Stub (stub => stub.CurrentFunction).Return (RootFunction).Repeat.Any(); ExecutionStateContextMock.Expect (mock => mock.SetExecutionState (Arg<RedirectingToSubFunctionState>.Is.NotNull)) .WhenCalled ( invocation => { var nextState = CheckExecutionState ((RedirectingToSubFunctionState) invocation.Arguments[0]); Assert.That ( nextState.Parameters.SubFunction.ReturnUrl, Is.EqualTo ("/session/root.wxe?Key=Value&WxeFunctionToken=" + WxeContext.FunctionToken)); Assert.That ( nextState.Parameters.DestinationUrl, Is.EqualTo ("/session/sub.wxe?Parameter1=OtherValue&WxeFunctionToken=" + SubFunction.FunctionToken)); }); MockRepository.ReplayAll(); executionState.ExecuteSubFunction (WxeContext); MockRepository.VerifyAll(); }
public void ExecuteSubFunction_UsesEventTarget() { IExecutionState executionState = CreateExecutionStateForSupressRepost(true); using (MockRepository.Ordered()) { using (MockRepository.Unordered()) { _pageMock.Expect(mock => mock.GetPostBackCollection()).Return(PostBackCollection); _pageMock.Expect(mock => mock.SaveAllState()); } ExecutionStateContextMock.Expect(mock => mock.SetExecutionState(Arg <ExecutingSubFunctionWithoutPermaUrlState> .Is.NotNull)) .WhenCalled( invocation => { var nextState = CheckExecutionState((ExecutingSubFunctionWithoutPermaUrlState)invocation.Arguments[0]); Assert.That(nextState.Parameters.PostBackCollection.AllKeys, Is.EquivalentTo(new[] { "Key", c_senderUniqueID })); }); } MockRepository.ReplayAll(); executionState.ExecuteSubFunction(WxeContext); MockRepository.VerifyAll(); }
public void ExecuteSubFunction_UsesEventTarget_SuppressSender_SenderRemains() { Control senderMock = MockRepository.StrictMock <Control> (); senderMock.Stub(stub => stub.UniqueID).Return(c_senderUniqueID).Repeat.Any(); IExecutionState executionState = new PreProcessingSubFunctionState( ExecutionStateContextMock, new PreProcessingSubFunctionStateParameters(_pageMock, SubFunction, WxePermaUrlOptions.Null), WxeRepostOptions.SuppressRepost(senderMock, true)); using (MockRepository.Ordered()) { using (MockRepository.Unordered()) { _pageMock.Expect(mock => mock.GetPostBackCollection()).Return(PostBackCollection); _pageMock.Expect(mock => mock.SaveAllState()); } ExecutionStateContextMock.Expect(mock => mock.SetExecutionState(Arg <ExecutingSubFunctionWithoutPermaUrlState> .Is.NotNull)) .WhenCalled( invocation => { var nextState = CheckExecutionState((ExecutingSubFunctionWithoutPermaUrlState)invocation.Arguments[0]); Assert.That(nextState.Parameters.PostBackCollection.AllKeys, Is.EquivalentTo(new[] { "Key", c_senderUniqueID })); }); } MockRepository.ReplayAll(); executionState.ExecuteSubFunction(WxeContext); MockRepository.VerifyAll(); }
public void ExecuteSubFunction_SuppressSender_IPostBackDataHandler() { Control senderMock = MockRepository.StrictMultiMock <Control> (typeof(IPostBackDataHandler)); senderMock.Stub(stub => stub.UniqueID).Return(c_senderUniqueID).Repeat.Any(); IExecutionState executionState = CreateExecutionStateForSupressRepost(senderMock); using (MockRepository.Ordered()) { using (MockRepository.Unordered()) { _pageMock.Expect(mock => mock.GetPostBackCollection()).Return(PostBackCollection); _pageMock.Expect(mock => mock.SaveAllState()); } ExecutionStateContextMock.Expect(mock => mock.SetExecutionState(Arg <ExecutingSubFunctionWithoutPermaUrlState> .Is.NotNull)) .WhenCalled( invocation => { var nextState = CheckExecutionState((ExecutingSubFunctionWithoutPermaUrlState)invocation.Arguments[0]); Assert.That(nextState.Parameters.PostBackCollection, Is.Not.SameAs(PostBackCollection)); Assert.That( nextState.Parameters.PostBackCollection.AllKeys, Is.EquivalentTo(new[] { "Key", ControlHelper.PostEventSourceID, ControlHelper.PostEventArgumentID })); }); } MockRepository.ReplayAll(); executionState.ExecuteSubFunction(WxeContext); MockRepository.VerifyAll(); }
public void ExecuteSubFunction_ReEntrancy_GoesToPostProcessingSubFunction() { using (MockRepository.Ordered()) { SubFunction.Expect(mock => mock.Execute(WxeContext)).WhenCalled(invocation => Thread.CurrentThread.Abort()); SubFunction.Expect(mock => mock.Execute(WxeContext)); ExecutionStateContextMock.Expect(mock => mock.SetExecutionState(Arg <IExecutionState> .Is.NotNull)); } MockRepository.ReplayAll(); try { _executionState.ExecuteSubFunction(WxeContext); Assert.Fail(); } catch (ThreadAbortException) { Thread.ResetAbort(); } _executionState.ExecuteSubFunction(WxeContext); MockRepository.VerifyAll(); }
public void ExecuteSubFunction_WithPermaUrl_WithParentPermaUrl_DoNotReturnToCaller_GoesToRedirectingToSubFunction () { WxeContext.QueryString.Add ("Key", "NewValue"); WxePermaUrlOptions permaUrlOptions = new WxePermaUrlOptions (true); IExecutionState executionState = CreateExecutionState (permaUrlOptions, WxeReturnOptions.Null); ExecutionStateContextMock.Expect (mock => mock.SetExecutionState (Arg<RedirectingToSubFunctionState>.Is.NotNull)) .WhenCalled ( invocation => { var nextState = CheckExecutionState ((RedirectingToSubFunctionState) invocation.Arguments[0]); Assert.That (nextState.Parameters.SubFunction.ReturnUrl, Is.EqualTo ("DefaultReturn.html")); string destinationUrl = UrlUtility.AddParameters ( "/session/sub.wxe", new NameValueCollection { { "Parameter1", "OtherValue" }, { WxeHandler.Parameters.WxeFunctionToken, SubFunction.FunctionToken }, { WxeHandler.Parameters.ReturnUrl, "/root.wxe?Key=NewValue" } }, Encoding.Default); Assert.That (nextState.Parameters.DestinationUrl, Is.EqualTo (destinationUrl)); }); MockRepository.ReplayAll(); executionState.ExecuteSubFunction (WxeContext); MockRepository.VerifyAll(); }
public void ExecuteSubFunction_WithPermaUrl() { WxePermaUrlOptions permaUrlOptions = new WxePermaUrlOptions(); IExecutionState executionState = CreateExecutionStateForDoRepost(null, permaUrlOptions); using (MockRepository.Ordered()) { using (MockRepository.Unordered()) { _pageMock.Expect(mock => mock.GetPostBackCollection()).Return(PostBackCollection); _pageMock.Expect(mock => mock.SaveAllState()); } ExecutionStateContextMock.Expect(mock => mock.SetExecutionState(Arg <PreparingRedirectToSubFunctionState> .Is.NotNull)) .WhenCalled( invocation => { var nextState = CheckExecutionState((PreparingRedirectToSubFunctionState)invocation.Arguments[0]); Assert.That(nextState.Parameters.PostBackCollection, Is.Not.SameAs(PostBackCollection)); Assert.That( nextState.Parameters.PostBackCollection.AllKeys, Is.EquivalentTo(new[] { "Key", c_senderUniqueID, ControlHelper.PostEventSourceID, ControlHelper.PostEventArgumentID })); Assert.That(nextState.Parameters.SubFunction.ParentStep, Is.SameAs(_parentStep)); Assert.That(nextState.Parameters.PermaUrlOptions, Is.SameAs(permaUrlOptions)); }); } MockRepository.ReplayAll(); executionState.ExecuteSubFunction(WxeContext); MockRepository.VerifyAll(); }
public void ExecuteSubFunction_GoesToExecutingSubFunction() { using (MockRepository.Ordered()) { ResponseMock.Expect(mock => mock.Redirect("~/destination.wxe")).WhenCalled(invocation => Thread.CurrentThread.Abort()); ExecutionStateContextMock.Expect(mock => mock.SetExecutionState(Arg <ExecutingSubFunctionWithPermaUrlState> .Is.NotNull)) .WhenCalled( invocation => { var nextState = CheckExecutionState((ExecutingSubFunctionWithPermaUrlState)invocation.Arguments[0]); Assert.That(nextState.Parameters.ResumeUrl, Is.EqualTo("~/resume.wxe")); }); } MockRepository.ReplayAll(); try { _executionState.ExecuteSubFunction(WxeContext); Assert.Fail(); } catch (ThreadAbortException) { Thread.ResetAbort(); } MockRepository.VerifyAll(); }
public override void SetUp() { base.SetUp(); _parentStep = new WxePageStep("page.aspx"); ExecutionStateContextMock.Stub(stub => stub.CurrentStep).Return(_parentStep).Repeat.Any(); _pageMock = MockRepository.StrictMock <IWxePage>(); PostBackCollection.Add("Key", "Value"); PostBackCollection.Add(c_senderUniqueID, "Value"); PostBackCollection.Add(ControlHelper.PostEventSourceID, "TheEventSource"); PostBackCollection.Add(ControlHelper.PostEventArgumentID, "TheEventArgument"); }
public void ExecuteSubFunction_GoesToPostProcessingSubFunction() { using (MockRepository.Ordered()) { SubFunction.Expect(mock => mock.Execute(WxeContext)); ExecutionStateContextMock.Expect(mock => mock.SetExecutionState(Arg <PostProcessingSubFunctionState> .Is.NotNull)) .WhenCalled(invocation => CheckExecutionState((PostProcessingSubFunctionState)invocation.Arguments[0])); } MockRepository.ReplayAll(); _executionState.ExecuteSubFunction(WxeContext); MockRepository.VerifyAll(); }
public void ExecuteSubFunction_WithPostRequest() { PrivateInvoke.SetNonPublicField(FunctionState, "_postBackID", 100); RequestMock.Stub(stub => stub.HttpMethod).Return("POST").Repeat.Any(); using (MockRepository.Ordered()) { ExecutionStateContextMock.Expect(mock => mock.SetReturnState(SubFunction, false, null)); ExecutionStateContextMock.Expect(mock => mock.SetExecutionState(NullExecutionState.Null)); } MockRepository.ReplayAll(); _executionState.ExecuteSubFunction(WxeContext); MockRepository.VerifyAll(); }
public void ExecuteSubFunction() { PrivateInvoke.SetNonPublicField(FunctionState, "_postBackID", 100); using (MockRepository.Ordered()) { ExecutionStateContextMock.Expect(mock => mock.SetReturnState(SubFunction, true, PostBackCollection)); ExecutionStateContextMock.Expect(mock => mock.SetExecutionState(NullExecutionState.Null)); } MockRepository.ReplayAll(); _executionState.ExecuteSubFunction(WxeContext); MockRepository.VerifyAll(); Assert.That(PostBackCollection[WxePageInfo.PostBackSequenceNumberID], Is.EqualTo("100")); }
public void ExecuteSubFunction_WithPermaUrl_DoNotReturnToCaller_GoesToRedirectingToSubFunction () { IExecutionState executionState = CreateExecutionState (new WxePermaUrlOptions(), WxeReturnOptions.Null); ExecutionStateContextMock.Expect (mock => mock.SetExecutionState (Arg<RedirectingToSubFunctionState>.Is.NotNull)) .WhenCalled ( invocation => { var nextState = CheckExecutionState ((RedirectingToSubFunctionState) invocation.Arguments[0]); Assert.That (nextState.Parameters.SubFunction.ReturnUrl, Is.EqualTo ("DefaultReturn.html")); Assert.That ( nextState.Parameters.DestinationUrl, Is.EqualTo ("/session/sub.wxe?Parameter1=OtherValue&WxeFunctionToken=" + SubFunction.FunctionToken)); }); MockRepository.ReplayAll(); executionState.ExecuteSubFunction (WxeContext); MockRepository.VerifyAll(); }
public void ExecuteSubFunction_WithPermaUrl_GoesToExecutingSubFunction() { WxePermaUrlOptions permaUrlOptions = new WxePermaUrlOptions(); IExecutionState executionState = CreateExecutionState(permaUrlOptions); ExecutionStateContextMock.Expect(mock => mock.SetExecutionState(Arg <RedirectingToSubFunctionState> .Is.NotNull)) .WhenCalled( invocation => { var nextState = CheckExecutionState((RedirectingToSubFunctionState)invocation.Arguments[0]); Assert.That( nextState.Parameters.DestinationUrl, Is.EqualTo("/session/sub.wxe?Parameter1=OtherValue&WxeFunctionToken=" + WxeContext.FunctionToken)); Assert.That(nextState.Parameters.ResumeUrl, Is.EqualTo("/session/root.wxe?WxeFunctionToken=" + WxeContext.FunctionToken)); }); MockRepository.ReplayAll(); executionState.ExecuteSubFunction(WxeContext); MockRepository.VerifyAll(); }
public void ExecuteSubFunction() { using (MockRepository.Ordered()) { ResponseMock.Expect(mock => mock.Redirect("/resumeUrl.wxe")).WhenCalled(invocation => Thread.CurrentThread.Abort()); ExecutionStateContextMock.Expect(mock => mock.SetExecutionState(Arg <PostProcessingSubFunctionState> .Is.NotNull)) .WhenCalled(invocation => CheckExecutionState((PostProcessingSubFunctionState)invocation.Arguments[0])); } MockRepository.ReplayAll(); try { _executionState.ExecuteSubFunction(WxeContext); Assert.Fail(); } catch (ThreadAbortException) { Thread.ResetAbort(); } MockRepository.VerifyAll(); }
public void ExecuteSubFunction_GoesToReturningFromSubFunction() { using (MockRepository.Ordered()) { SubFunction.Expect(mock => mock.Execute(WxeContext)); ExecutionStateContextMock.Expect( mock => mock.SetExecutionState(Arg <IExecutionState> .Is.NotNull)) .WhenCalled( invocation => { Assert.That(invocation.Arguments[0], Is.InstanceOf(typeof(ReturningFromSubFunctionState))); var nextState = (ReturningFromSubFunctionState)invocation.Arguments[0]; Assert.That(nextState.ExecutionStateContext, Is.SameAs(ExecutionStateContextMock)); Assert.That(nextState.Parameters.SubFunction, Is.SameAs(SubFunction)); Assert.That(nextState.Parameters.ResumeUrl, Is.EqualTo("/resumeUrl.wxe")); }); } MockRepository.ReplayAll(); _executionState.ExecuteSubFunction(WxeContext); MockRepository.VerifyAll(); }