示例#1
0
        public override void OnExecutionPlay(WxeContext context, IWxeFunctionExecutionListener listener)
        {
            ArgumentUtility.CheckNotNull("context", context);
            ArgumentUtility.CheckNotNull("listener", listener);

            listener.OnExecutionPlay(context);
        }
示例#2
0
        private void ContextOpenSampleFunctionWithPermanentUrlInNewWindowButton_Click(object sender, System.EventArgs e)
        {
            NameValueCollection queryString = new NameValueCollection();

            queryString.Add("Parameter", "Hello World!");
            WxeContext.ExecuteFunctionExternal(this, new SampleWxeFunction(), "_blank", string.Empty, true, queryString);
        }
        private void Return(WxeContext context)
        {
            ArgumentUtility.CheckNotNull("context", context);

            NameValueCollection postBackCollection;

            if (StringUtility.AreEqual(context.HttpContext.Request.HttpMethod, "POST", false))
            {
                postBackCollection = context.HttpContext.Request.Form;
            }
            else
            {
                postBackCollection = context.HttpContext.Request.QueryString;
            }

            postBackCollection = postBackCollection.Clone();
            if (_backedUpPostBackData != null)
            {
                foreach (var key in _backedUpPostBackData.AllKeys)
                {
                    postBackCollection[key] = _backedUpPostBackData[key];
                }
            }
            else
            {
                postBackCollection.Remove(ControlHelper.PostEventSourceID);
                postBackCollection.Remove(ControlHelper.PostEventArgumentID);
            }
            _pageStep.SetReturnState(_function, true, postBackCollection);

            _backedUpPostBackData = null;

            _isReturningPostBack = true;
        }
        public override void ExecuteSubFunction(WxeContext context)
        {
            ArgumentUtility.CheckNotNull("context", context);

            Parameters.SubFunction.Execute(context);
            ExecutionStateContext.SetExecutionState(new ReturningFromSubFunctionState(ExecutionStateContext, Parameters));
        }
示例#5
0
        public void CreateTransactionStrategy_WithParentTransaction()
        {
            ITransactionMode transactionMode = new CreateChildIfParentTransactionMode(true, new TestTransactionFactory());

            WxeFunction parentFunction = new TestFunction2(new CreateRootTransactionMode(true, new TestTransactionFactory()));
            WxeFunction childFunction  = new TestFunction2(transactionMode);

            parentFunction.Add(childFunction);

            WxeStep stepMock = MockRepository.GenerateMock <WxeStep>();

            childFunction.Add(stepMock);

            WxeContextFactory wxeContextFactory = new WxeContextFactory();
            WxeContext        context           = wxeContextFactory.CreateContext(new TestFunction());

            stepMock.Expect(mock => mock.Execute(context)).WhenCalled(
                invocation =>
            {
                TransactionStrategyBase strategy = ((TestFunction2)childFunction).TransactionStrategy;
                Assert.That(strategy, Is.InstanceOf(typeof(ChildTransactionStrategy)));
                Assert.That(((ChildTransactionStrategy)strategy).AutoCommit, Is.True);
                Assert.That(strategy.OuterTransactionStrategy, Is.SameAs(((TestFunction2)parentFunction).TransactionStrategy));
            });

            parentFunction.Execute(context);
        }
示例#6
0
        public override void OnExecutionFail(WxeContext context, IWxeFunctionExecutionListener listener, Exception exception)
        {
            ArgumentUtility.CheckNotNull("context", context);
            ArgumentUtility.CheckNotNull("listener", listener);

            listener.OnExecutionFail(context, exception);
        }
示例#7
0
        private void ContextOpenSampleFunctionButton_Click(object sender, System.EventArgs e)
        {
            NameValueCollection queryString = new NameValueCollection();

            queryString.Add("Parameter", "Hello World!");
            WxeContext.ExecuteFunctionExternal(this, new SampleWxeFunction(), queryString, true);
        }
示例#8
0
        public void GetStaticPermanentUrlWithEmptyQueryString()
        {
            string expectedUrl  = UrlUtility.GetAbsoluteUrl(new HttpContextWrapper(_currentHttpContext), _resource);
            string permanentUrl = WxeContext.GetPermanentUrl(new HttpContextWrapper(_currentHttpContext), _functionType, new NameValueCollection());

            Assert.That(permanentUrl, Is.Not.Null);
            Assert.That(permanentUrl, Is.EqualTo(expectedUrl));
        }
示例#9
0
        public void SetUp()
        {
            WxeContextFactory contextFactory = new WxeContextFactory();

            _context = contextFactory.CreateContext(new TestFunction());

            _executionListener = NullExecutionListener.Null;
        }
示例#10
0
        public virtual void SetUp()
        {
            _currentHttpContext = HttpContextHelper.CreateHttpContext("GET", "default.html", null);
            HttpContextHelper.SetCurrent(_currentHttpContext);

            _currentWxeContext = new WxeContextMock(_currentHttpContext);
            WxeContext.SetCurrent(_currentWxeContext);
        }
示例#11
0
        public void GetStaticPermanentUrlWithDefaultWxeHandlerForMappedFunctionType()
        {
            WebConfigurationMock.Current = WebConfigurationFactory.GetExecutionEngineWithDefaultWxeHandler();

            string expectedUrl  = UrlUtility.GetAbsoluteUrl(new HttpContextWrapper(_currentHttpContext), _resource);
            string permanentUrl = WxeContext.GetPermanentUrl(new HttpContextWrapper(_currentHttpContext), _functionType, new NameValueCollection());

            Assert.That(permanentUrl, Is.Not.Null);
            Assert.That(permanentUrl, Is.EqualTo(expectedUrl));
        }
        public void SetUp()
        {
            WxeContextFactory wxeContextFactory = new WxeContextFactory();

            _context = wxeContextFactory.CreateContext(new TestFunction());

            _executionListenerMock = MockRepository.GenerateMock <IWxeFunctionExecutionListener> ();

            _strategy = NullTransactionStrategy.Null;
        }
示例#13
0
        public override void ExecuteSubFunction(WxeContext context)
        {
            NameValueCollection postBackCollection = BackupPostBackCollection();

            Parameters.Page.SaveAllState();

            var parameters = new PreparingRedirectToSubFunctionStateParameters(Parameters.SubFunction, postBackCollection, Parameters.PermaUrlOptions);

            ExecutionStateContext.SetExecutionState(new PreparingRedirectToSubFunctionState(ExecutionStateContext, parameters, _returnOptions));
        }
        public void Execute(WxeContext context)
        {
            ArgumentUtility.CheckNotNull("context", context);

            _pageStep.SetPostBackCollection(_postBackCollection);
            _postBackCollection = null;
            _function.Execute(context);

            Return(context);
        }
示例#15
0
        public void SetUp()
        {
            TestFunction      rootFunction   = new TestFunction();
            WxeContextFactory contextFactory = new WxeContextFactory();

            _context        = contextFactory.CreateContext(rootFunction);
            _mockRepository = new MockRepository();

            _executionListenerMock = _mockRepository.StrictMock <IWxeFunctionExecutionListener>();
        }
        public void CreateTransactionStrategy_WithoutParentFunction()
        {
            WxeContextFactory wxeContextFactory = new WxeContextFactory();
            WxeContext        context           = wxeContextFactory.CreateContext(new TestFunction());

            ITransactionMode        transactionMode = new NoneTransactionMode();
            TransactionStrategyBase strategy        = transactionMode.CreateTransactionStrategy(new TestFunction2(transactionMode), context);

            Assert.That(strategy, Is.InstanceOf(typeof(NoneTransactionStrategy)));
            Assert.That(strategy.OuterTransactionStrategy, Is.SameAs(NullTransactionStrategy.Null));
        }
示例#17
0
        public void GetStaticPermanentUrlWithQueryStringExceedingMaxLength()
        {
            string parameterName  = "Param";
            string parameterValue = "123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 ";

            NameValueCollection queryString = new NameValueCollection();

            queryString.Add(parameterName, parameterValue);

            WxeContext.GetPermanentUrl(new HttpContextWrapper(_currentHttpContext), _functionType, queryString);
        }
示例#18
0
        public override void Execute(WxeContext context)
        {
            var delay = Delay;

            if (delay.HasValue)
            {
                Thread.Sleep(delay.Value);
            }

            base.Execute(context);
        }
示例#19
0
        public void SetUp()
        {
            WxeContextFactory wxeContextFactory = new WxeContextFactory();

            _context = wxeContextFactory.CreateContext(new TestFunction());

            _executionListenerMock        = MockRepository.GenerateMock <IWxeFunctionExecutionListener>();
            _executionContextMock         = MockRepository.GenerateMock <IWxeFunctionExecutionContext>();
            _outerTransactionStrategyMock = MockRepository.GenerateMock <TransactionStrategyBase>();
            _strategy = new NoneTransactionStrategy(_outerTransactionStrategyMock);
        }
        public void SetUp()
        {
            _mockRepository = new MockRepository();
            WxeContextFactory wxeContextFactory = new WxeContextFactory();

            _wxeContext = wxeContextFactory.CreateContext(new TestFunction());

            _securityAdapterMock = _mockRepository.StrictMock <IWxeSecurityAdapter>();
            _innerListenerMock   = _mockRepository.StrictMock <IWxeFunctionExecutionListener>();

            _function = new TestFunction();
        }
示例#21
0
        public override void ExecuteSubFunction(WxeContext context)
        {
            ArgumentUtility.CheckNotNull("context", context);

            string destinationUrl = GetDestinationPermanentUrl(context);
            string resumeUrl      = context.GetResumeUrl(false);

            ExecutionStateContext.SetExecutionState(
                new RedirectingToSubFunctionState(
                    ExecutionStateContext,
                    new RedirectingToSubFunctionStateParameters(Parameters.SubFunction, Parameters.PostBackCollection, destinationUrl, resumeUrl)));
        }
示例#22
0
        //TODO: CleanUp duplication with other PostProcessSubFunction-implemenations
        public override void ExecuteSubFunction(WxeContext context)
        {
            ArgumentUtility.CheckNotNull("context", context);

            // Correct the PostBack-Sequence number
            Parameters.PostBackCollection[WxePageInfo.PostBackSequenceNumberID] = context.PostBackID.ToString();

            //  Provide the executed sub-function and backed up postback data to the executing page
            ExecutionStateContext.SetReturnState(Parameters.SubFunction, true, Parameters.PostBackCollection);

            ExecutionStateContext.SetExecutionState(NullExecutionState.Null);
        }
        public void ExecuteFunctionState()
        {
            CurrentHttpContext.Items["Test"] = new object();
            _wxeHandler.ExecuteFunctionState(CurrentHttpContext, _functionStateWithEnabledCleanUp, true);
            TestFunction function = (TestFunction)_functionStateWithEnabledCleanUp.Function;

            WxeContext wxeContext = function.TestStep.WxeContext;

            Assert.That(wxeContext, Is.SameAs(WxeContext.Current));
            Assert.That(wxeContext.HttpContext.Items["Test"], Is.SameAs(CurrentHttpContext.Items["Test"]));
            Assert.That(wxeContext.FunctionToken, Is.EqualTo(_functionStateWithEnabledCleanUp.FunctionToken));
            Assert.That(function.LastExecutedStepID, Is.EqualTo("4"));
        }
        /// <summary>Play is invoked when the function's <see cref="WxeFunction.Execute(WxeContext)"/> method is invoked (first and subsequent calls).</summary>
        public void OnExecutionPlay(WxeContext context)
        {
            ArgumentUtility.CheckNotNull("context", context);

            if (!_function.IsExecutionStarted)
            {
                if (_wxeSecurityAdapter != null)
                {
                    _wxeSecurityAdapter.CheckAccess(_function);
                }
            }

            _innerListener.OnExecutionPlay(context);
        }
示例#25
0
        public void SetUp()
        {
            TestFunction      rootFunction   = new TestFunction();
            WxeContextFactory contextFactory = new WxeContextFactory();

            _wxeContext             = contextFactory.CreateContext(rootFunction);
            _mockRepository         = new MockRepository();
            _mockWxeSecurityAdapter = _mockRepository.StrictMock <IWxeSecurityAdapter> ();

            var serviceLocator = DefaultServiceLocator.Create();

            serviceLocator.RegisterMultiple <IWxeSecurityAdapter> (() => _mockWxeSecurityAdapter);
            _serviceLocatorScope = new ServiceLocatorScope(serviceLocator);
        }
示例#26
0
        public void CreateTransactionStrategy_WithoutParentFunction_And_WithoutParentTransaction()
        {
            WxeContextFactory wxeContextFactory = new WxeContextFactory();
            WxeContext        context           = wxeContextFactory.CreateContext(new TestFunction());

            ITransactionMode        transactionMode = new CreateChildIfParentTransactionMode(true, new TestTransactionFactory());
            TransactionStrategyBase strategy        = transactionMode.CreateTransactionStrategy(new TestFunction2(transactionMode), context);

            Assert.That(strategy, Is.InstanceOf(typeof(RootTransactionStrategy)));
            Assert.That(strategy.GetNativeTransaction <TestTransaction>(), Is.InstanceOf(typeof(TestTransaction)));
            Assert.That(((RootTransactionStrategy)strategy).AutoCommit, Is.True);
            Assert.That(((RootTransactionStrategy)strategy).Transaction, Is.InstanceOf(typeof(TestTransaction)));
            Assert.That(strategy.OuterTransactionStrategy, Is.InstanceOf(typeof(NullTransactionStrategy)));
        }
        public override void ExecuteSubFunction(WxeContext context)
        {
            ArgumentUtility.CheckNotNull("context", context);

            try
            {
                context.HttpContext.Response.Redirect(Parameters.DestinationUrl);
                throw new InvalidOperationException(string.Format("Redirect to '{0}' failed.", Parameters.DestinationUrl));
            }
            catch (ThreadAbortException)
            {
                ExecutionStateContext.SetExecutionState(new PostProcessingSubFunctionState(ExecutionStateContext, Parameters));
                throw;
            }
        }
        public override void OnExecutionPlay(WxeContext context, IWxeFunctionExecutionListener listener)
        {
            ArgumentUtility.CheckNotNull("context", context);
            ArgumentUtility.CheckNotNull("listener", listener);

            if (_scope != null)
            {
                throw new InvalidOperationException(
                          "OnExecutionPlay may not be invoked twice without calling OnExecutionStop, OnExecutionPause, or OnExecutionFail in-between.");
            }

            ExecuteAndWrapInnerException(EnterScope, null);

            _child.OnExecutionPlay(context, listener);
        }
        public void ExecuteFunction()
        {
            TestFunction function = (TestFunction)_functionStateWithEnabledCleanUp.Function;

            _wxeHandler.ExecuteFunction(function, CurrentWxeContext, true);

            WxeContext wxeContext = function.TestStep.WxeContext;

            Assert.That(wxeContext, Is.SameAs(WxeContext.Current));

            Type[] catchExceptionTypes = function.ExceptionHandler.GetCatchExceptionTypes();
            Assert.That(catchExceptionTypes.Length, Is.EqualTo(1));
            Assert.That(catchExceptionTypes[0], Is.SameAs(typeof(WxeUserCancelException)));

            Assert.That(function.LastExecutedStepID, Is.EqualTo("4"));
        }
        public void ExecutePage(WxeContext context, string page, bool isPostBack)
        {
            ArgumentUtility.CheckNotNull("context", context);
            ArgumentUtility.CheckNotNullOrEmpty("page", page);

            string url         = page;
            string queryString = context.HttpContext.Request.Url.Query;

            if (!string.IsNullOrEmpty(queryString))
            {
                queryString = queryString.Replace(":", HttpUtility.UrlEncode(":"));
                if (url.Contains("?"))
                {
                    url = url + "&" + queryString.TrimStart('?');
                }
                else
                {
                    url = url + queryString;
                }
            }

            WxeHandler wxeHandlerBackUp = context.HttpContext.Handler as WxeHandler;

            Assertion.IsNotNull(wxeHandlerBackUp, "The HttpHandler must be of type WxeHandler.");
            try
            {
                context.HttpContext.Server.Transfer(url, isPostBack);
            }
            catch (HttpException httpException)
            {
                if (httpException.InnerException is WxeExecutionControlException)
                {
                    return;
                }

                if (httpException.GetHttpCode() == HttpStatusCode_NotFound)
                {
                    throw new WxeResourceNotFoundException(string.Format("The page '{0}' does not exist.", page), httpException);
                }

                throw;
            }
            finally
            {
                context.HttpContext.Handler = wxeHandlerBackUp;
            }
        }