Example #1
0
        public void TestDefaultPathElementWithExplicitPathRelativeFromRootNamespace()
        {
            TemplateSettings settings = MockApplication.GetDefaultSettings <DefaultPathElementWithExplicitPathRelativeFromRootNamespace>("DefaultPathElementWithExplicitPathRelativeFromRootNamespace");

            settings.templateResolutionBasePath = Path.Combine(UnityEngine.Application.dataPath, "..", "Packages", "UIForia", "Tests");
            settings.styleBasePath = "Data";

            MockApplication app = MockApplication.Setup <DefaultPathElementWithExplicitPathRelativeFromRootNamespace>(settings);

            app.Update();
            Assert.IsInstanceOf <DefaultPathElementWithExplicitPathRelativeFromRootNamespace>(app.RootElement);
        }
Example #2
0
        public void CustomLoaderTemplates()
        {
            TemplateSettings settings = MockApplication.GetDefaultSettings <CustomPathElement>("CustomLoaderTemplates");

            settings.templateResolutionBasePath = Path.Combine(UnityEngine.Application.dataPath, "..", "Packages", "UIForia", "Tests");
            settings.styleBasePath    = "Data.TemplateLoading";
            settings.filePathResolver = (type, templateId) => {
                // throwing a bit of random totally custom path resolution code in here. this should just demonstrate that you have full power
                string customElementPath = type.Name.Replace("Element", "");
                return(Path.Combine(
                           settings.templateResolutionBasePath,
                           settings.styleBasePath.Replace('.', Path.DirectorySeparatorChar),
                           customElementPath,
                           customElementPath + ".xml"));
            };

            MockApplication app = MockApplication.Setup <CustomPathElement>(settings);

            app.Update();
            Assert.IsInstanceOf <CustomPathElement>(app.RootElement);
        }