public void Execute() { _pageExecutorMock.Expect(mock => mock.ExecutePage(_wxeContext, "~/ThePage", false)).WhenCalled( invocation => { Assert.That(_pageStep.PostBackCollection, Is.Null); Assert.That(_pageStep.IsReturningPostBack, Is.False); }); _mockRepository.ReplayAll(); _pageStep.Execute(_wxeContext); _mockRepository.VerifyAll(); Assert.That(_pageStep.IsPostBack, Is.False); }
public void Test_SubFunctionCompleted_ReEntrancy() { WxeContextMock.SetCurrent(_wxeContext); using (_mockRepository.Ordered()) { using (_mockRepository.Unordered()) { _pageMock.Expect(mock => mock.GetPostBackCollection()).Return(_postBackCollection); _pageMock.Expect(mock => mock.SaveAllState()); _pageMock.Expect(mock => mock.WxeHandler).Return(_wxeHandler); } _subFunction.Expect(mock => mock.Execute(_wxeContext)).WhenCalled(invocation => Thread.CurrentThread.Abort()); _pageExecutorMock.Expect(mock => mock.ExecutePage(_wxeContext, "~/ThePage", true)); } _mockRepository.ReplayAll(); try { WxePermaUrlOptions permaUrlOptions = WxePermaUrlOptions.Null; WxeRepostOptions repostOptions = WxeRepostOptions.DoRepost(null); _pageStep.ExecuteFunction(new PreProcessingSubFunctionStateParameters(_pageMock, _subFunction, permaUrlOptions), repostOptions); Assert.Fail(); } catch (ThreadAbortException) { Thread.ResetAbort(); } _pageStep.Execute(); _mockRepository.VerifyAll(); }
public void Test_ReturnToCaller() { NameValueCollection callerUrlParameters = new NameValueCollection { { "CallerKey", "CallerValue" } }; using (_mockRepository.Ordered()) { using (_mockRepository.Unordered()) { _pageMock.Expect(mock => mock.GetPostBackCollection()).Return(_postBackCollection); _pageMock.Expect(mock => mock.SaveAllState()); _pageMock.Expect(mock => mock.WxeHandler).Return(_wxeHandler); } //Redirect to external subfunction _responseMock .Expect(mock => mock.Redirect(Arg <string> .Matches(arg => arg == "/session/sub.wxe?WxeFunctionToken=" + _subFunction.FunctionToken))) .WhenCalled(invocation => Thread.CurrentThread.Abort()); //Show external sub function _subFunction.Expect(mock => mock.Execute(_wxeContext)).WhenCalled( invocation => { PrivateInvoke.SetNonPublicField(_functionState, "_postBackID", 100); _pageStep.SetPostBackCollection(new NameValueCollection()); Thread.CurrentThread.Abort(); }); //Return from external sub function _subFunction.Expect(mock => mock.Execute(_wxeContext)).Throw(new WxeExecuteNextStepException()); _requestMock.Expect(mock => mock.HttpMethod).Return("GET"); _pageExecutorMock.Expect(mock => mock.ExecutePage(_wxeContext, "~/ThePage", true)).WhenCalled( invocation => { Assert.That(((IExecutionStateContext)_pageStep).ExecutionState, Is.SameAs(NullExecutionState.Null)); Assert.That(_pageStep.PostBackCollection[WxePageInfo.PostBackSequenceNumberID], Is.EqualTo("100")); Assert.That(_pageStep.PostBackCollection.AllKeys, Has.Member("Key")); Assert.That(_pageStep.ReturningFunction, Is.SameAs(_subFunction)); Assert.That(_pageStep.IsReturningPostBack, Is.True); }); } _mockRepository.ReplayAll(); WxePermaUrlOptions permaUrlOptions = new WxePermaUrlOptions(); try { //Redirect to external subfunction WxeReturnOptions returnOptions = new WxeReturnOptions(callerUrlParameters); _pageStep.ExecuteFunctionExternalByRedirect(new PreProcessingSubFunctionStateParameters(_pageMock, _subFunction, permaUrlOptions), returnOptions); Assert.Fail(); } catch (ThreadAbortException) { Thread.ResetAbort(); } try { //Show external sub function _subFunction.Execute(); Assert.Fail(); } catch (ThreadAbortException) { Thread.ResetAbort(); } try { //Return from external sub function _subFunction.Execute(); Assert.Fail(); } catch (WxeExecuteNextStepException) { } Assert.That(_subFunction.ReturnUrl, Is.EqualTo("/session/root.wxe?CallerKey=CallerValue&WxeFunctionToken=" + _rootFunction.FunctionToken)); //Show current page _pageStep.Execute(); _mockRepository.VerifyAll(); }