Inheritance: IDisposable
 public void SetUp()
 {
     // ensure, uiCulture and culture are set to different cultures
     CultureTestScope.Set();
     TestWebContext.Create("/apppath", "testpage.aspx");
     DoSetUp();
 }
 public static void ThrowsArgumentExceptionOnNonExistingPathImpl()
 {
     using (TestWebContext ctx = new TestWebContext("/Test", "testform.aspx"))
     {
         WebObjectDefinitionFactory factory = new WebObjectDefinitionFactory();
         IWebObjectDefinition definition
             = (IWebObjectDefinition)factory.CreateObjectDefinition("/Test/DoesNotExist.aspx", "parentdefinition", AppDomain.CurrentDomain);
     }
 }
 public static void ResolvesToPageRootDefinitionIfEndsWithASPXImpl()
 {
     using (TestWebContext ctx = new TestWebContext("/Test", "testform.aspx"))
     {
         WebObjectDefinitionFactory factory = new WebObjectDefinitionFactory();
         IWebObjectDefinition definition
             = (IWebObjectDefinition)factory.CreateObjectDefinition("/Test/testform.aspx", null, AppDomain.CurrentDomain);
         Assert.IsNotNull(definition, "CreateObjectDefinition with no parent is returning null (it must never do so).");
         Assert.IsTrue(definition.IsPage, ".aspx extension must result in a page instance");
         Assert.AreEqual(typeof(RootWebObjectDefinition), definition.GetType());
     }
 }
Exemple #4
0
 public static void Create(string virtualPath, string page)
 {
     _wc = new TestWebContext(virtualPath, page);
 }
 public void TearDown()
 {
     DoTearDown();
     TestWebContext.Release();
     CultureTestScope.Reset();
 }
 public static void Create(string virtualPath, string page)
 {
     _wc = new TestWebContext(virtualPath, page);
 }
        public void RunTestWithDI()
        {
//            LogManager.Adapter = new Common.Logging.Simple.TraceLoggerFactoryAdapter();

            DataView dv = CreateDataSource();
            using (TestWebContext wctx = new TestWebContext("/testpath", "testpage.aspx"))
            {
                IApplicationContext ctx = new WebApplicationContext();

                int runs = 1000;

                StopWatch watch = new StopWatch();
                using (watch.Start("Duration: {0}"))
                {
                    for (int i = 0; i < runs; i++)
                    {
                        DataGrid grid = new DataGrid();
                        Spring.Web.Support.WebDependencyInjectionUtils.InjectDependenciesRecursive(ctx, grid);
                        grid.DataSource = dv;
                        grid.DataBind();
                    }
                }

                using (watch.Start("Duration: {0}"))
                {
                    for (int i = 0; i < runs; i++)
                    {
                        DataGrid grid = new DataGrid();
                        grid.DataSource = dv;
                        grid.DataBind();
                        Spring.Web.Support.WebDependencyInjectionUtils.InjectDependenciesRecursive(ctx, grid);
                    }
                }
            }
        }
 public static void BCLPageHandlerFactoryBehaviorImpl()
 {
     using (TestWebContext ctx = new TestWebContext("/Test", "DoesNotExist.oaspx"))
     {
         try
         {
             IHttpHandlerFactory phf = (IHttpHandlerFactory)Activator.CreateInstance(typeof(System.Web.UI.Page).Assembly.GetType("System.Web.UI.PageHandlerFactory"), true);
             phf.GetHandler(HttpContext.Current, "GET", ctx.HttpWorkerRequest.GetFilePath(), ctx.HttpWorkerRequest.GetFilePathTranslated());
         }
         catch (HttpException e)
         {
             Assert.AreEqual(404, e.GetHttpCode());
             Assert.IsTrue(e.Message.IndexOf(ctx.HttpWorkerRequest.GetFilePath()) > 0);
         }
     }
 }
 public static void PageHandlerFactoryBehavesLikeSystemPageHandlerFactoryImpl()
 {
     using (TestWebContext ctx = new TestWebContext("/Test", "DoesNotExist.aspx"))
     {
         try
         {
             IHttpHandlerFactory phf = new PageHandlerFactory();
             phf.GetHandler(HttpContext.Current, "GET", ctx.HttpWorkerRequest.GetFilePath(), ctx.HttpWorkerRequest.GetFilePathTranslated());
         }
         catch (HttpException e)
         {
             Assert.AreEqual(404, e.GetHttpCode());
             Assert.IsTrue(e.Message.IndexOf(ctx.HttpWorkerRequest.GetFilePath()) > 0);
         }
     }
 }