public void TestRefresh() { string tempTile = Path.GetTempFileName(); File.Copy("a.htm", tempTile, true); try { var config = new MockConfiguration(tempTile, new DateTime(2007, 1, 1)) {Factory = _factory }; var ts = new TilesSet(config); Assert.That(RequiresRefresh(ts, "a"), Is.False); Assert.That(RequiresRefresh(ts, "b"), Is.False); File.SetLastWriteTime(tempTile, DateTime.Now.AddDays(-1)); config.ConfigurationLastModified = config.ConfigurationLastModified.Value.AddDays(1); Assert.That(RequiresRefresh(ts, "a"), Is.True); Assert.That(RequiresRefresh(ts, "b"), Is.False); ts.Refresh(); Assert.That(RequiresRefresh(ts, "a"), Is.False); Assert.That(RequiresRefresh(ts, "b"), Is.False); } finally { File.Delete(tempTile); } }
public void DecorateOfOnlyOneFileTiles() { var config = new MockConfiguration("a", DateTime.Now) {Factory = _locatorFactory}; config.Entries.Add(new MockTileEntry { Name = "a", Path = "a.htm" }); var set = TilesFactory.AssembleFor(config).Map; Assert.That(set.Tiles.Count, Is.EqualTo(1)); Assert.That(set.Contains("a")); }
public void DecorateOfOneFileOneAttributeTiles() { var config = new MockConfiguration("a", DateTime.Now) { Factory = _locatorFactory }; config.Entries.Add(new MockTileEntry { Name = "a", Path = "a.htm", TileAttributes = new List<IAttributeEntry>{new MockAttributeEntry { Name="b", Value = "value" }} }); var set = TilesFactory.AssembleFor(config).Map; Assert.That(set.Tiles.Count, Is.EqualTo(1)); Assert.That(set.Contains("a")); TemplateTile tile = (TemplateTile) set.Get("a"); Assert.That(tile.Attributes, Is.Not.Null); Assert.That(tile.Attributes.Count, Is.EqualTo(1)); Assert.That(tile.Attributes["b"], Is.Not.Null); }
public void CreatorShouldAssembleTileAttributeShoulApplyFilePrefix() { var entry = new XmlAttributeEntry { Name = "name", Value = "a.htm", Type = TileType.File.ToString() }; var config = new MockConfiguration("a.htm", DateTime.Now) { Factory = _locatorFactory }; var factory = new TilesFactory(config); var tile = new TemplateTileAttributeCreator().Create(entry, factory); Assert.That(tile, Is.Not.Null); config.FilePrefix = @"nonexisting\"; try { new TemplateTileAttributeCreator().Create(entry, factory); } catch (TileException Te) { Console.WriteLine(Te.Message); Assert.That(Te.Message.Contains("a.htm could not be found")); } }
public void TestRefreshConfig() { var config = new MockConfiguration(new DateTime(2007, 1, 1)) { Factory = _factory }; var ts = new TilesSet(config); Assert.That(ts.Contains("a")); Assert.That(ts.Contains("b")); Assert.That(!ts.Contains("c")); config.RefreshAndChange(new DateTime(2008, 1, 1)); ts.Refresh(); Assert.That(ts.Contains("a")); Assert.That(ts.Contains("b")); Assert.That(ts.Contains("c")); }
public void CreatorShouldAssembleFileTileWhenTileIsFilledShouldTakePrefixIntoAccount() { var config = new MockConfiguration() {Factory = _locatorFactory}; _factory = new TilesFactory(config); var entry = new XmlAttributeEntry { Name = "name", Value = "a.htm", }; var tile = new AutoTileAttributeCreator().Create(entry, _factory); Assert.That(tile, Is.Not.Null); config.FilePrefix = @"nonexisting\"; try { new AutoTileAttributeCreator().Create(entry, _factory); } catch (TileException Te) { Assert.That(Te.Message.Contains("not find a part of the path")); } }
public void SetUp() { _lib = new TagLib(); _lib.Register(new Tags.Tiles()); _lib.Register(new Sharp()); _locatorFactory = new FileLocatorFactory().CloneForTagLib(_lib) as FileLocatorFactory; var config = new MockConfiguration() {Factory = _locatorFactory }; _factory = new TilesFactory(config); }