Example #1
0
        public void TestRefreshConfigByFile()
        {
            string tempTile = Path.GetTempFileName();

            File.Copy("Configuration\\tiles.smallconfig.xml", tempTile, true);
            File.SetLastWriteTime(tempTile, DateTime.Now.AddDays(-1));
            try
            {
                var config = new TileXmlConfigurator(_lib, tempTile);
                var ts     = new TilesSet(config);

                Assert.That(ts.Contains("a"));
                Assert.That(ts.Contains("b"));
                Assert.That(!ts.Contains("c"));

                File.Copy("Configuration\\tiles.config.xml", tempTile, true);
                ts.Refresh();

                Assert.That(ts.Contains("a"));
                Assert.That(ts.Contains("b"));
                Assert.That(ts.Contains("c"));
            }
            finally
            {
                File.Delete(tempTile);
            }
        }
Example #2
0
 protected void InitFactory(Assembly assembly)
 {
     if (_factory == null)
     {
         _assembly = assembly;
         Type   factoryType = null;
         String prefix      = null;
         try
         {
             var config = TilesConfigurationSection.Get();
             factoryType = config.ResourceFactoryType;
             prefix      = config.FilePrefix;
             RefreshJob.REFRESH_INTERVAL = config.RefreshIntervalSeconds;
         }
         catch
         {
             Debug.WriteLine("No config section found for tiles, using assembly configuration");
         }
         _factory = factoryType == null
                        ?
                    new AssemblyLocatorFactory(_assembly, prefix).CloneForTagLib(_lib)
                        :
                    TileXmlConfigurator.GetCustomFactory(_lib, factoryType);
     }
 }
Example #3
0
        public void TilesWithExtendsReltionssAttributesShouldLoadCorrectly()
        {
            var xmlConfig = new TileXmlConfigurator(_lib, "Configuration/tiles.with.extends.xml");
            var set       = new TilesSet(xmlConfig);

            Assert.That(set.Tiles.Count, Is.EqualTo(4));
            Assert.That(set["a"], Is.Not.Null);
        }
Example #4
0
        public void TilesWithAutoAttributesShouldLoadCorrectly()
        {
            var xmlConfig = new TileXmlConfigurator(_lib, "Configuration/tiles.with.auto.properties.xml");
            var set       = new TilesSet(xmlConfig);

            Assert.That(set.Tiles.Count, Is.EqualTo(3));
            Assert.That(set["a"], Is.Not.Null);
        }
Example #5
0
        public void DeserializeFromAssemlbyWithTilesConfigurationFileShouldLoadTilesSet()
        {
            var configurator = new TileXmlConfigurator(
                _lib,
                Assembly.GetAssembly(typeof(TileXmlConfiguratorTest)));
            var set = new TilesSet(configurator);

            Assert.That(set.Tiles.Count, Is.EqualTo(3));
            Assert.That(GetPath(set["a"]), Is.EqualTo("embedded_a.htm"));
            Assert.That(GetPath(set["b"]), Is.EqualTo("embedded_b.htm"));
            Assert.That(GetPath(set["c"]), Is.EqualTo("embedded_c.htm"));
        }
Example #6
0
        public void FilePrefixOnTilesDefinitionsWrong()
        {
            var xmlConfig = new TileXmlConfigurator(_lib, "tiles.config.xml", "Configuration/");

            try
            {
                new TilesSet(xmlConfig);
                Assert.Fail("Should fail");
            }
            catch (TemplateException Te)
            {
                Console.WriteLine(Te.Message);
                Assert.IsTrue(Te.Message.Contains(@"Configuration\a.htm"));
            }
        }
Example #7
0
        static TemplateField()
        {
            TagLib = new TagLib();

            TilesConfigurationSection config = TilesConfigurationSection.Get();
            var prefix = TemplateFieldPrefixHelper.BuildPrefix(HostingEnvironment.ApplicationPhysicalPath, config.FilePrefix);

            RefreshJob.REFRESH_INTERVAL = config.RefreshIntervalSeconds;
            _configuration = new TileXmlConfigurator(
                TagLib,
                config.ConfigFilePath,
                prefix
                );
            TILES = new TilesSet(_configuration);
        }