示例#1
0
        public string AspxToString(string aspx)
        {
            StringBuilder sb = new StringBuilder();

            using (StringWriter sw = new StringWriter(sb))
            {
                using (HtmlTextWriter tw = new HtmlTextWriter(sw))
                {
                    var workerRequest = new SimpleWorkerRequest(aspx, "", tw);
                    HttpContext.Current = new HttpContext(workerRequest);

                    object view = BuildManager.CreateInstanceFromVirtualPath(aspx, typeof(object));

                    Page viewPage = view as Page;
                    if (viewPage == null)
                    {
                        UserControl viewUserControl = view as UserControl;
                        if (viewUserControl != null)
                        {
                            viewPage = new Page();
                            viewPage.Controls.Add(viewUserControl);
                        }
                    }

                    if (viewPage != null)
                    {
                        HttpContext.Current.Server.Execute(viewPage, tw, true);

                        return(sb.ToString());
                    }

                    throw new InvalidOperationException();
                }
            }
        }
示例#2
0
 private static HttpApplication GetApplicationInstance()
 {
     var writer = new StringWriter();
     var workerRequest = new SimpleWorkerRequest("", "", writer);
     var httpContext = new HttpContext(workerRequest);
     return (HttpApplication)getApplicationInstanceMethod.Invoke(null, new object[] { httpContext });
 }
示例#3
0
        public void GetUriPath()
        {
            StringWriter        sw  = new StringWriter();
            SimpleWorkerRequest swr = new SimpleWorkerRequest("/", cwd, String.Empty, String.Empty, sw);

            Assert.AreEqual("/", swr.GetUriPath(), "GetUriPath");

            swr = new SimpleWorkerRequest(String.Empty, cwd, String.Empty, String.Empty, sw);
            Assert.AreEqual("/", swr.GetUriPath(), "GetUriPath-2");

            swr = new SimpleWorkerRequest(String.Empty, cwd, "/", String.Empty, sw);
            Assert.AreEqual("//", swr.GetUriPath(), "GetUriPath-3");

            swr = new SimpleWorkerRequest("/", cwd, "/", String.Empty, sw);
            Assert.AreEqual("//", swr.GetUriPath(), "GetUriPath-4");

            swr = new SimpleWorkerRequest("virtual", cwd, "/", String.Empty, sw);
            Assert.AreEqual("virtual//", swr.GetUriPath(), "GetUriPath-5");

            swr = new SimpleWorkerRequest("/virtual", cwd, "/", String.Empty, sw);
            Assert.AreEqual("/virtual//", swr.GetUriPath(), "GetUriPath-6");

            swr = new SimpleWorkerRequest("/virtual/", cwd, "/", String.Empty, sw);
            Assert.AreEqual("/virtual///", swr.GetUriPath(), "GetUriPath-7");

            swr = new SimpleWorkerRequest("virtual", cwd, "page", String.Empty, sw);
            Assert.AreEqual("virtual/page", swr.GetUriPath(), "GetUriPath-8");

            swr = new SimpleWorkerRequest("/virtual", cwd, "page", String.Empty, sw);
            Assert.AreEqual("/virtual/page", swr.GetUriPath(), "GetUriPath-9");

            swr = new SimpleWorkerRequest("/virtual/", cwd, "page", String.Empty, sw);
            Assert.AreEqual("/virtual//page", swr.GetUriPath(), "GetUriPath-a");
        }
示例#4
0
 public void FixtureSetUp()
 {
     // we're at full trust here
     sw  = new StringWriter();
     cwd = Environment.CurrentDirectory;
     swr = new SimpleWorkerRequest("/", cwd, String.Empty, String.Empty, sw);
 }
 public static void SetHttpContext()
 {
     SimpleWorkerRequest simpleWorkerRequest = new SimpleWorkerRequest(string.Empty, string.Empty, string.Empty, null, new StringWriter());
     HttpContext.Current = new HttpContext(simpleWorkerRequest);
     HttpContext.Current.Request.Cookies.Add(new HttpCookie(UserRequestModel_Keys.WcfClientCultureSelectedCookieName, currentCultureName));
     Thread.CurrentThread.CurrentCulture = GlobalizationHelper.CultureInfoGetOrDefault(currentCultureName);
 }
示例#6
0
    public void Execute(string page)
    {
        SimpleWorkerRequest req = new SimpleWorkerRequest(
            page, "", Console.Out);

        HttpRuntime.ProcessRequest(req);
    }
示例#7
0
        protected void BtnLoad_Click(object sender, EventArgs e)
        {
            Page p = BuildManager.CreateInstanceFromVirtualPath(this.TxtPageVirtualPath.Text, typeof(Page)) as Page;

            List <String> controlList = new List <String>();

            MemoryStream   ms  = new MemoryStream();
            TextWriter     tw  = new StreamWriter(ms);
            HtmlTextWriter htw = new HtmlTextWriter(tw);

            //this is necessary, Otherwise "Default.aspx" will show the contents of "WebForm1.aspx".
            HttpWorkerRequest hwr         = new SimpleWorkerRequest(this.TxtPageVirtualPath.Text, "", tw);
            HttpContext       fakeContext = new HttpContext(hwr);

            ((IHttpHandler)p).ProcessRequest(fakeContext);

            //I could not compile this part in VS2005
            //ResourceManager.AddControls(p.Controls, controlList);


            this.TxtListControls.Text = "";
            foreach (Control ctr in p.Controls)
            {
                this.TxtListControls.Text += this.recursiveControls(p, "");
            }
        }
示例#8
0
        public void MyTestInitialize()
        {
            var request = new SimpleWorkerRequest("/dummy", @"c:\inetpub\wwwroot\dummy", "dummy.html", null, new StringWriter());

            HttpContext.Current = new HttpContext(request);
            SessionStateUtility.AddHttpSessionStateToContext(HttpContext.Current, new HttpSessionState2());
        }
示例#9
0
        public UmbracoTestFixture()
        {
            Customize(new AutoNSubstituteCustomization());

            ContextAccessor          = this.Freeze <IUmbracoContextAccessor>();
            MediaUrlProvider         = this.Freeze <IMediaUrlProvider>();
            UrlProvider              = this.Freeze <IUrlProvider>();
            PublishedSnapshotService = this.Freeze <IPublishedSnapshotService>();
            VariationContextAccessor = this.Freeze <IVariationContextAccessor>();
            DefaultCultureAccessor   = this.Freeze <IDefaultCultureAccessor>();
            GlobalSettings           = this.Freeze <IGlobalSettings>();
            UserService              = this.Freeze <IUserService>();
            DomainCache              = this.Freeze <IDomainCache>();
            RedirectUrlService       = this.Freeze <IRedirectUrlService>();
            UmbracoSettingsSection   = this.Freeze <UmbracoSettingsSection>();

            SimpleWorkerRequest = new SimpleWorkerRequest("/", @"c:\", "null.aspx", string.Empty, TextWriter.Null);

            ContextFactory = new UmbracoContextFactory(
                ContextAccessor,
                PublishedSnapshotService,
                VariationContextAccessor,
                DefaultCultureAccessor,
                UmbracoSettingsSection,
                GlobalSettings,
                new UrlProviderCollection(new[] { UrlProvider }),
                new MediaUrlProviderCollection(new[] { MediaUrlProvider }),
                UserService);
        }
示例#10
0
        public static void EnsureContext()
        {
            if (UmbracoContext.Current != null)
            {
                return;
            }

            var request     = new SimpleWorkerRequest("", "", "", null, new StringWriter());
            var httpContext = new HttpContextWrapper(new HttpContext(request));

            Mock <WebSecurity> webSecurity = new Mock <WebSecurity>(httpContext, ApplicationContext.Current);
            var currentUser = Mock.Of <IUser>(u =>
                                              u.IsApproved &&
                                              u.Name == Utility.RandomString() &&
                                              u.Id == Utility.CurrentUserId);

            webSecurity.Setup(x => x.CurrentUser).Returns(currentUser);

            UmbracoContext.EnsureContext(
                httpContext,
                ApplicationContext.Current,
                webSecurity.Object,
                UmbracoConfig.For.UmbracoSettings(),
                Mock.Of <IEnumerable <IUrlProvider> >(),
                false);
        }
示例#11
0
        static void Main(string[] args)
        {
            // Create the application host
            object host = ApplicationHost.CreateApplicationHost(typeof(MyHost), "/", "c:\\");

            int request_count = 10;

            SimpleWorkerRequest [] requests = new SimpleWorkerRequest[request_count];

            int pos;

            for (pos = 0; pos != request_count; pos++)
            {
                requests[pos] = new SimpleWorkerRequest("test.aspx", "", Console.Out);
            }

            ModulesConfiguration.Add("syncmodule", typeof(SyncModule).AssemblyQualifiedName);
            ModulesConfiguration.Add("asyncmodule", typeof(AsyncModule).AssemblyQualifiedName);

            HandlerFactoryConfiguration.Add("get", "/", typeof(AsyncHandler).AssemblyQualifiedName);
            //HandlerFactoryConfiguration.Add("get", "/", typeof(SyncHandler).AssemblyQualifiedName);

            for (pos = 0; pos != request_count; pos++)
            {
                HttpRuntime.ProcessRequest(requests[pos]);
            }

            HttpRuntime.Close();

/*
 *                      Console.Write("Press Enter to quit.");
 *                      Console.WriteLine();
 *                      Console.ReadLine();
 */
        }
示例#12
0
        protected void Application_Start(object sender, EventArgs e)
        {
            TextWriter        tw = new StringWriter();
            HttpWorkerRequest wr = new SimpleWorkerRequest("default.aspx", "friendId=1300000000", tw);

            HttpContext.Current = new HttpContext(wr);

            var a = Toolkit.GetTypeURL <int>();
            var b = Toolkit.GetTypeURL <int?>();
            var c = Toolkit.GetTypeURL <string>();
            var d = Toolkit.GetTypeURL <int[]>();
            var f = Toolkit.GetTypeURL <MyClass[]>();
            var g = Toolkit.GetTypeURL <List <string> >();
            var h = Toolkit.GetTypeURL <List <IEnumerable <MyClass> > >();
            var i = Toolkit.GetTypeURL <List <KeyValuePair <MyClass, Global> > >();
            var j = Toolkit.GetTypeURL <List <KeyValuePair <MyClass, MyStruct> > >();

            var a1 = Toolkit.GetHtmlString(a);
            var b1 = Toolkit.GetHtmlString(b);
            var c1 = Toolkit.GetHtmlString(c);
            var d1 = Toolkit.GetHtmlString(d);
            var f1 = Toolkit.GetHtmlString(f);
            var g1 = Toolkit.GetHtmlString(g);
            var h1 = Toolkit.GetHtmlString(h);
            var i1 = Toolkit.GetHtmlString(i);
            var j1 = Toolkit.GetHtmlString(j);
        }
        public HttpContextRhinoMocker()
        {
            SimpleWorkerRequest request = new SimpleWorkerRequest("/dummy", @"c:\inetpub\wwwroot\cetrea\newsfeed", "dummy.html", null, new StringWriter());
            HttpContext         context = new HttpContext(request);

            //_serverVariables.Add("", "");

            _httpContext   = MockRepository.GenerateMock <HttpContextBase>();
            _httpRequest   = MockRepository.GenerateMock <HttpRequestBase>();
            _httpResponse  = MockRepository.GenerateMock <HttpResponseBase>();
            _httpSession   = MockRepository.GenerateMock <HttpSessionStateBase>();
            _httpServer    = MockRepository.GenerateMock <HttpServerUtilityBase>();
            _userPrincipal = MockRepository.GenerateMock <IPrincipal>();
            _userIdentity  = MockRepository.GenerateMock <IIdentity>();

            _httpContext.Stub(x => x.Request).Return(_httpRequest);
            _httpContext.Stub(x => x.Response).Return(_httpResponse);
            _httpContext.Stub(x => x.Cache).Return(context.Cache);
            _httpContext.Stub(x => x.Session).Return(_httpSession);
            _httpContext.Stub(x => x.Server).Return(_httpServer);
            _httpContext.Stub(x => x.User).Return(_userPrincipal);

            _userPrincipal.Stub(x => x.Identity).Return(_userIdentity);
            _userIdentity.Stub(x => x.Name).Return("guest");

            _httpRequest.Stub(x => x.ServerVariables).Return(_serverVariables);
            _httpRequest.Stub(x => x.ApplicationPath).Return("/newsfeed");
            //ApplicationConfigHolder.HttpContextBase = _httpContext;
        }
示例#14
0
            public void MapPathOnEmptyVirtualDir()
            {
                StringWriter        sw  = new StringWriter();
                SimpleWorkerRequest swr = new SimpleWorkerRequest("file.aspx", "querystring", sw);

                swr.MapPath("/");
            }
        public string Render_SimpleWorkerRequest(SimpleWorkerRequest simpleWorkerRequest, StringWriter stringWriter)
        {
            HttpRuntime.ProcessRequest(simpleWorkerRequest);
            var response = stringWriter.ToString();

            return(response);
        }
示例#16
0
            public void Exception3()
            {
                StringWriter        sw  = new StringWriter();
                SimpleWorkerRequest swr = new SimpleWorkerRequest("file.aspx", "querystring", sw);

                swr.MapPath("appVirtualDir/file.aspx");
            }
示例#17
0
    public static HttpContextBase FakeHttpContext(string relativePath, string absolutePath, params string[] routePaths)
    {
        var httpContext = new Mock <HttpContextBase>();
        var request     = new Mock <HttpRequestBase>();
        var response    = new Mock <HttpResponseBase>();
        var session     = new Mock <HttpSessionStateBase>();
        var server      = new Mock <HttpServerUtilityBase>();
        var cookies     = new HttpCookieCollection();

        httpContext.Setup(x => x.Server).Returns(server.Object);
        httpContext.Setup(x => x.Session).Returns(session.Object);
        httpContext.Setup(x => x.Request).Returns(request.Object);
        httpContext.Setup(x => x.Response).Returns(response.Object);
        response.Setup(x => x.Cookies).Returns(cookies);
        httpContext.SetupGet(x => x.Request.Url).Returns(new Uri("http://localhost:300"));
        httpContext.SetupGet(x => x.Request.UserHostAddress).Returns("127.0.0.1");
        if (!String.IsNullOrEmpty(relativePath))
        {
            server.Setup(x => x.MapPath(relativePath)).Returns(absolutePath);
        }
        // used for matching routes within calls to Url.Action
        foreach (var path in routePaths)
        {
            var localPath = path;
            response.Setup(x => x.ApplyAppPathModifier(localPath)).Returns(localPath);
        }
        var writer = new StringWriter();
        var wr     = new SimpleWorkerRequest("", "", "", "", writer);

        HttpContext.Current = new HttpContext(wr);
        return(httpContext.Object);
    }
    /// <summary>
    /// Retrieve specific section value from the web.config
    /// </summary>
    /// <param name="configSection">Main Web.config section</param>
    /// <param name="subSection">Child Section{One layer down}</param>
    /// <param name="innersection">Keyed on Section Name</param>
    /// <param name="propertyName">Element property name</param>
    /// <returns></returns>
    /// <example>string setting = MercuryCRM.Common.Utilities.SiteSupport.RetrieveApplicationSetting("applicationSettings", "Mercury.UPSWorldship.Properties.Settings", "ShipWS_ShipWebReference_ShipService", "value")</example>
    public static string RetrieveApplicationSetting(string configSection, string subSection, string innersection, string propertyName)
    {
        string            result            = string.Empty;
        HttpWorkerRequest fakeWorkerRequest = null;

        try {
            using (TextWriter textWriter = new StringWriter()) {
                fakeWorkerRequest = new SimpleWorkerRequest("default.aspx", "", textWriter);
                var           fakeHTTPContext = new HttpContext(fakeWorkerRequest);
                Configuration config          = ConfigurationManager.OpenMappedExeConfiguration(new ExeConfigurationFileMap()
                {
                    ExeConfigFilename = fakeHTTPContext.Server.MapPath(@"~/Web.config")
                }, ConfigurationUserLevel.None);
                ConfigurationSectionGroup group = config.SectionGroups[configSection];
                if (group != null)
                {
                    ClientSettingsSection clientSection = group.Sections[subSection] as ClientSettingsSection;
                    if (clientSection != null)
                    {
                        SettingElement settingElement = clientSection.Settings.Get(innersection);
                        if (settingElement != null)
                        {
                            result = (((SettingValueElement)(settingElement.ElementInformation.Properties[propertyName].Value)).ValueXml).InnerText;
                        }
                    }
                }
            }
        } catch (Exception ex) {
            throw ex;
        } finally {
            fakeWorkerRequest.CloseConnection();
        }
        return(result);
    }
示例#19
0
        /// <summary>
        /// </summary>
        /// <param name="filename">
        /// </param>
        /// <param name="queryString">
        /// </param>
        /// <returns>
        /// </returns>
        private string ProcessFile(string filename, string queryString)
        {
            var sw           = new StringWriter();
            var simpleWorker = new SimpleWorkerRequest(filename, queryString, sw);

            HttpRuntime.ProcessRequest(simpleWorker);
            return(sw.ToString());
        }
示例#20
0
        public void GetFilePathTest()
        {
            SimpleWorkerRequest reference = new SimpleWorkerRequest("/webapp", "c:\\webapp\\", "default.aspx", "", null);

            AspNetWorker worker = GetHttpWorker("/webapp", "c:\\webapp\\");

            Assert.AreEqual(reference.GetFilePath(), worker.GetFilePath());
        }
示例#21
0
        public void Go(string hostname, string page, string queryString)
        {
            var sw = new StringWriter();
            var wr = new SimpleWorkerRequest(page, queryString, sw);

            // This causes ASP.NET to process the request
            HttpRuntime.ProcessRequest(wr);
        }
    public static TPage CreatePage <TPage>(string virtualPath) where TPage : Page
    {
        var page    = BuildManager.CreateInstanceFromVirtualPath(virtualPath, typeof(TPage)) as TPage;
        var request = new SimpleWorkerRequest(virtualPath, null, null);

        page.ProcessRequest(new HttpContext(request));
        return(page);
    }
 public string ProcessRequest(string page, string query)
 {
     using (StringWriter sw = new StringWriter())
     {
         SimpleWorkerRequest work = new SimpleWorkerRequest(page, query, sw);
         HttpRuntime.ProcessRequest(work);
         return(sw.ToString());
     }
 }
 public void ProcessPage(string url)
 {
     using (StreamWriter sw = new StreamWriter("C:\temp.html"))
     {
         SimpleWorkerRequest worker = new SimpleWorkerRequest(url, null, sw);
         HttpRuntime.ProcessRequest(worker);
     }
     // Ta-dah!  C:\temp.html has some html for you.
 }
	//In a base class that inherits Page:
		internal string RenderPage() {
			var request = new SimpleWorkerRequest("", null, null);
			ProcessRequest(new HttpContext(request));
			using (var writer = new StringWriter(CultureInfo.InvariantCulture)) {
				using (var htmlWriter = new HtmlTextWriter(writer))
					RenderControl(htmlWriter);
				return writer.ToString();
			}
		}
示例#26
0
        public void CreateHtmlPage(String webPage,
                                   String query)
        {
            SimpleWorkerRequest swr = new SimpleWorkerRequest(webPage,
                                                              query,
                                                              Console.Out);

            HttpRuntime.ProcessRequest(swr);
        }
示例#27
0
        //
        // This tests the constructor when the user code creates an HttpContext
        //
        [Test] public void ConstructorTests()
        {
            StringWriter sw = new StringWriter();

            SimpleWorkerRequest swr;

            swr = new SimpleWorkerRequest("/appVirtualDir", cwd, "pageVirtualPath", "querystring", sw);
            Assert.AreEqual("/appVirtualDir", swr.GetAppPath(), "S1");
            Assert.AreEqual("/appVirtualDir/pageVirtualPath", swr.GetFilePath(), "S2");
            Assert.AreEqual("GET", swr.GetHttpVerbName(), "S3");
            Assert.AreEqual("HTTP/1.0", swr.GetHttpVersion(), "S4");
            Assert.AreEqual("127.0.0.1", swr.GetLocalAddress(), "S5");
            Assert.AreEqual(80, swr.GetLocalPort(), "S6");
            Assert.AreEqual("querystring", swr.GetQueryString(), "S7");
            Assert.AreEqual("127.0.0.1", swr.GetRemoteAddress(), "S8");
            Assert.AreEqual(0, swr.GetRemotePort(), "S9");
            Assert.AreEqual("/appVirtualDir/pageVirtualPath?querystring", swr.GetRawUrl(), "S10");
            Assert.AreEqual("/appVirtualDir/pageVirtualPath", swr.GetUriPath(), "S11");
            Assert.AreEqual("0", swr.GetUserToken().ToString(), "S12");
            Assert.AreEqual(null, swr.MapPath("x"), "S13");
            Assert.AreEqual(null, swr.MachineConfigPath, "S14");
            Assert.AreEqual(null, swr.MachineInstallDirectory, "S15");
            Assert.AreEqual(Path.Combine(cwd, "pageVirtualPath"), swr.GetFilePathTranslated(), "S16");
            Assert.AreEqual("", swr.GetServerVariable("AUTH_TYPE"), "S18");
            Assert.AreEqual("", swr.GetServerVariable("AUTH_USER"), "S19");
            Assert.AreEqual("", swr.GetServerVariable("REMOTE_USER"), "S20");
            Assert.AreEqual("", swr.GetServerVariable("SERVER_SOFTWARE"), "S21");
            Assert.AreEqual("/appVirtualDir/pageVirtualPath", swr.GetUriPath(), "S22");

            //
            // MapPath
            //
            Assert.AreEqual(null, swr.MapPath("file.aspx"), "MP1");
            Assert.AreEqual(null, swr.MapPath("/appVirtualDir/pageVirtualPath"), "MP2");
            Assert.AreEqual(null, swr.MapPath("appVirtualDir/pageVirtualPath"), "MP3");
            Assert.AreEqual(null, swr.MapPath("/appVirtualDir/pageVirtualPath/page.aspx"), "MP4");
            Assert.AreEqual(null, swr.MapPath("/appVirtualDir/pageVirtualPath/Subdir"), "MP5");

            swr = new SimpleWorkerRequest("/appDir", cwd, "/Something/page.aspx", "querystring", sw);

            //Assert.AreEqual ("c:\\tmp\\page.aspx", swr.GetFilePathTranslated (), "S17");

            //
            // GetUriPath tests, veredict: MS implementation is a bit fragile on this interface
            //
            swr = new SimpleWorkerRequest("/appDir", cwd, "/page.aspx", null, sw);
            Assert.AreEqual("/appDir//page.aspx", swr.GetUriPath(), "S23");

            swr = new SimpleWorkerRequest("/appDir/", cwd, "/page.aspx", null, sw);
            Assert.AreEqual("/appDir///page.aspx", swr.GetUriPath(), "S24");

            swr = new SimpleWorkerRequest("/appDir/", cwd, "page.aspx", null, sw);
            Assert.AreEqual("/appDir//page.aspx", swr.GetUriPath(), "S25");

            swr = new SimpleWorkerRequest("/appDir", cwd, "page.aspx", null, sw);
            Assert.AreEqual("/appDir/page.aspx", swr.GetUriPath(), "S26");
        }
示例#28
0
        static RouteUtils()
        {
            Ctx = new RequestContext(new RewritedHttpContextBase("/"), new RouteData());

            TextWriter tw      = new StringWriter();
            var        request = new SimpleWorkerRequest("/", string.Empty, tw);
            var        context = new HttpContextWrapper(new HttpContext(request));

            Ctx2 = new RequestContext(context, new RouteData());
        }
示例#29
0
        public void PathInfos()
        {
            SimpleWorkerRequest wr = new SimpleWorkerRequest("/appDir", "", "page.aspx/pathinfo", "", null);
            HttpContext         c  = new HttpContext(wr);

            Assert.AreEqual("http://127.0.0.1/appDir/page.aspx/pathinfo", c.Request.Url.AbsoluteUri);
            Assert.AreEqual("/appDir/page.aspx", c.Request.FilePath);
            Assert.AreEqual("/appDir/page.aspx/pathinfo", c.Request.Path);
            Assert.AreEqual("/pathinfo", c.Request.PathInfo);
        }
        public void TestBuildSiteMap()
        {
            PopulateSiteMapTable();

            MySqlSiteMapProvider prov   = new MySqlSiteMapProvider();
            NameValueCollection  config = new NameValueCollection();

            config.Add("connectionStringName", "LocalMySqlServer");
            config.Add("applicationName", "/");
            config.Add("enableExpireCallback", "false");

            prov.Initialize("SiteMapTests", config);
            prov.BuildSiteMap();
            SiteMapNode         node = prov.FindSiteMapNodeFromKey("5");
            SimpleWorkerRequest req  = new SimpleWorkerRequest("/dummy", Environment.CurrentDirectory, "default.aspx", null, new StringWriter());

            HttpContext.Current = new HttpContext(req);

            Assert.Equal(node.Title, "Evan's Gambit");
            SiteMapNode nodep = prov.GetParentNode(node);

            Assert.Equal(node.Description, "The Funny Italian Game");
            Assert.False(node.HasChildNodes);
            SiteMapNode node2 = node.NextSibling;

            Assert.NotNull(node2);
            Assert.Equal(node2.Title, "Sicilian Defense");
            Assert.Equal(node2.Description, "Sharp Double Edge Defense");

            node = node.PreviousSibling;
            Assert.NotNull(node);
            Assert.Equal(node.Title, "Ruy Lopez");
            Assert.Equal(node.Description, "The spanish opening");
            Assert.False(node.HasChildNodes);
            Assert.NotNull(node.NextSibling);

            node = node.ParentNode;
            Assert.Equal(node.Title, "Chess Openings");

            node = node.ParentNode;
            Assert.Equal(node.Title, "Index");

            node = node.ParentNode;
            Assert.Null(node);

            node = prov.RootNode;
            Assert.Equal(node.Title, "Index");
            string[] childData = new string[] { "Chess Openings", "Middle Game", "Endings" };

            for (int i = 0; i < node.ChildNodes.Count; i++)
            {
                SiteMapNode child = node.ChildNodes[i];
                Assert.Equal(child.Title, childData[i]);
            }
        }
        protected ControllerTestBase()
        {
            _previousDataDirectory = AppDomain.CurrentDomain.GetData("DataDirectory");
            AppDomain.CurrentDomain.SetData("DataDirectory", Path.GetTempPath());

            //HttpContext Hack
            var request = new SimpleWorkerRequest("", "", "", null, new StringWriter());
            var context = new HttpContext(request);

            HttpContext.Current = context;
        }
 public TheForgotPasswordMethod()
 {
     // Fake out env for VirtualPathUtility.ToAbsolute(..)
     string path = AppDomain.CurrentDomain.BaseDirectory;
     const string virtualDir = "/";
     AppDomain.CurrentDomain.SetData(".appDomain", "*");
     AppDomain.CurrentDomain.SetData(".appPath", path);
     AppDomain.CurrentDomain.SetData(".appVPath", virtualDir);
     AppDomain.CurrentDomain.SetData(".hostingVirtualPath", virtualDir);
     AppDomain.CurrentDomain.SetData(".hostingInstallDir", HttpRuntime.AspInstallDirectory);
     var tw = new StringWriter();
     HttpWorkerRequest wr = new SimpleWorkerRequest("default.aspx", "", tw);
     HttpContext.Current = new HttpContext(wr);
 }
示例#33
0
    public void Execute(string
page)
    {
        SimpleWorkerRequest
        req
        =
        new
        SimpleWorkerRequest
        (
        page,
        "",
        Console.Out);
        HttpRuntime.ProcessRequest
        (req);
    }
示例#34
0
文件: test.cs 项目: mono/gert
	public void Execute (string page, TextWriter tw)
	{
		SimpleWorkerRequest req = new SimpleWorkerRequest (
			page, "", tw);
		HttpRuntime.ProcessRequest (req);
	}