Test environment implementation.
Inheritance: IVirtualEnvironment, IDisposable
        public void ParsesPagePathIntoObjectNameIfNeitherIdNorNameAttributeSpecified()
        {
            const string CONTEXTPATH = "/ContextPath/";

            const string xml =
                @"<?xml version='1.0' encoding='UTF-8' ?>
<objects xmlns='http://www.springframework.net'>
    <object type='MyPage.aspx' />
    <object type='~/MyControl.ascx' />
</objects>";

            WebObjectFactory objectFactory = new WebObjectFactory(CONTEXTPATH, false);
            TestWebObjectDefinitionReader reader = new TestWebObjectDefinitionReader(objectFactory.ContextPath, objectFactory, new XmlUrlResolver());

            using (VirtualEnvironmentMock env = new VirtualEnvironmentMock(CONTEXTPATH + "test.aspx", null, null, CONTEXTPATH, true))
            {
                env.VirtualPath2ArtifactsTable[CONTEXTPATH + "MyPage.aspx"] = typeof (Spring.Web.UI.Page);
                env.VirtualPath2ArtifactsTable[CONTEXTPATH + "MyControl.ascx"] = typeof (Spring.Web.UI.UserControl);

                reader.LoadObjectDefinitions(new StringResource(xml));
            }

            Assert.IsTrue(objectFactory.ContainsObjectDefinition("/MyPage.aspx"));
            Assert.AreEqual(typeof(Spring.Web.UI.Page), objectFactory.GetType("/MyPage.aspx"));
            Assert.IsTrue(objectFactory.ContainsObjectDefinition("Spring.Web.UI.UserControl"));
        }
        public void ControlDefinitionsGetMarkedAbstract()
        {
            const string CONTEXTPATH = "/ContextPath/";
            const string xml =
                @"<?xml version='1.0' encoding='UTF-8' ?>
<objects xmlns='http://www.springframework.net'>
    <object type='MyControl.ascx' />
</objects>";

            WebObjectFactory objectFactory = new WebObjectFactory(CONTEXTPATH, false);
            TestWebObjectDefinitionReader reader = new TestWebObjectDefinitionReader(objectFactory.ContextPath, objectFactory, new XmlUrlResolver());

            using (VirtualEnvironmentMock env = new VirtualEnvironmentMock(CONTEXTPATH + "test.aspx", null, null, CONTEXTPATH, true))
            {
                env.VirtualPath2ArtifactsTable[CONTEXTPATH + "MyControl.ascx"] = typeof(Spring.Web.UI.UserControl);

                reader.LoadObjectDefinitions(new StringResource(xml));
            }

            Assert.IsTrue(objectFactory.ContainsObjectDefinition("Spring.Web.UI.UserControl"));
            Assert.IsTrue(objectFactory.GetObjectDefinition("Spring.Web.UI.UserControl").IsAbstract);
        }
Ejemplo n.º 3
0
 public void SetUpFixture()
 {
     testVirtualEnvironment = new VirtualEnvironmentMock("/some.request", "somepathinfo", null, "/", true);
 }
Ejemplo n.º 4
0
 public RewriteContext(string originalPath, bool rebaseClientPath, VirtualEnvironmentMock runtime)
 {
     this.originalPath = originalPath;
     this.rebaseClientPath = rebaseClientPath;
     this.runtime = runtime;
 }
Ejemplo n.º 5
0
 public RewriteContext(string originalPath, bool rebaseClientPath, VirtualEnvironmentMock runtime)
 {
     this.originalPath     = originalPath;
     this.rebaseClientPath = rebaseClientPath;
     this.runtime          = runtime;
 }
        public void DoesNotGenerateObjectNameIfIdAndNameAttributeSpecified()
        {
            const string CONTEXTPATH = "/";
            const string xml =
                @"<?xml version='1.0' encoding='UTF-8' ?>
<objects xmlns='http://www.springframework.net'>
    <object id='mypage' name='mypageAlias' type='~/MyPage.aspx' />
    <object id='mycontrol' name='mycontrolAlias' type='~/MyControl.ascx' />
</objects>";

            WebObjectFactory objectFactory = new WebObjectFactory(CONTEXTPATH, false);
            TestWebObjectDefinitionReader reader = new TestWebObjectDefinitionReader(objectFactory.ContextPath, objectFactory, new XmlUrlResolver());

            using (VirtualEnvironmentMock env = new VirtualEnvironmentMock(CONTEXTPATH + "test.aspx", null, null, CONTEXTPATH, true))
            {
                env.VirtualPath2ArtifactsTable[CONTEXTPATH + "MyPage.aspx"] = typeof(Spring.Web.UI.Page);
                env.VirtualPath2ArtifactsTable[CONTEXTPATH + "MyControl.ascx"] = typeof(Spring.Web.UI.UserControl);

                reader.LoadObjectDefinitions(new StringResource(xml));
            }

            Assert.IsTrue(objectFactory.ContainsObjectDefinition("mypage"));
            Assert.IsTrue(objectFactory.ContainsObject("mypageAlias"));
            Assert.IsTrue(objectFactory.ContainsObjectDefinition("mycontrol"));
            Assert.IsTrue(objectFactory.ContainsObject("mycontrolAlias"));
        }