public void CreatorShouldNotApplyWhenAttributeTileTypeIsNotSet()
 {
     var entry = new XmlAttributeEntry
                     {
                         Type = null
                     };
     Assert.That(new DefinitionTileAttributeCreator().Applies(entry), Is.False);
 }
 public void CreatorShouldNotApplyWhenAttributeTileTypeIsSetToOtherValueThanDefinition()
 {
     var entry = new XmlAttributeEntry
                     {
                         Type = TileType.String.ToString()
                     };
     Assert.That(new DefinitionTileAttributeCreator().Applies(entry), Is.False);
 }
 public void CreatorShouldApplyWhenAttributeTileTypeIsSetToDefinition()
 {
     var entry = new XmlAttributeEntry
                     {
                         Type = TileType.Definition.ToString()
                     };
     Assert.That(new DefinitionTileAttributeCreator().Applies(entry));
 }
 public void WhenNoTypeSpecifiedTileTypeShouldReturnNull()
 {
     var entry = new XmlAttributeEntry
                     {
                         Type = null
                     };
     Assert.That(entry.TileType, Is.Null);
 }
 public void CreatorShouldApplyWhenAttributeTileTypeIsSetToFile()
 {
     var entry = new XmlAttributeEntry
                     {
                         Type = TileType.File.ToString()
                     };
     Assert.That(new TemplateTileAttributeCreator().Applies(entry));
 }
 public void WhenTypeSpecifiedTileTypeShouldReturnTheMatchingEnum()
 {
     var entry = new XmlAttributeEntry
     {
         Type = TileType.Definition.ToString()
     };
     Assert.That(entry.TileType, Is.EqualTo(TileType.Definition));
 }
 public void CreatorShouldApplyWhenAttributeTileTypeIsNotSet()
 {
     var entry = new XmlAttributeEntry
                     {
                         Type = null
                     };
     Assert.That(new AutoTileAttributeCreator().Applies(entry));
 }
 public void CreatorShouldAssembleTileAttributeWithEmbeddedStringTile()
 {
     var entry = new XmlAttributeEntry
                     {
                         Name = "name",
                         Value = "value",
                         Type = TileType.String.ToString()
                     };
     TileAttribute tile = new StringTileAttributeCreator().Create(entry, null);
     Assert.That(tile, Is.Not.Null);
     Assert.That(tile.Name, Is.EqualTo("name"));
     Assert.That(tile.Value, Is.Not.Null);
     Assert.That(tile.Value.GetType(), Is.EqualTo(typeof (StringTile)));
     Assert.That(((StringTile) tile.Value).Value, Is.EqualTo("value"));
 }
 public void WhenTypeSpecifiedIsntAValidEnumValueTileTypeShouldThrowException()
 {
     var entry = new XmlAttributeEntry
     {
         Type = "unkown"
     };
     try
     {
         var type = entry.TileType;
         Assert.Fail("Expected error, shouldn't exist"+type);
     }
     catch (ArgumentException Ae)
     {
         Assert.That(Ae.Message.Contains("unkown"));
     }
 }
        public void CreatorShouldAssembleTileAttributeWithEmbeddedDefinitionTile()
        {
            var factory = new TilesFactory(new MockConfiguration());

            var entry = new XmlAttributeEntry
                            {
                                Name = "name",
                                Value = "definition",
                                Type = TileType.Definition.ToString()
                            };
            TileAttribute tile = new DefinitionTileAttributeCreator().Create(entry, factory);
            Assert.That(tile, Is.Not.Null);
            Assert.That(tile.Name, Is.EqualTo("name"));
            Assert.That(tile.Value, Is.Not.Null);
            Assert.That(tile.Value.GetType(), Is.EqualTo(typeof (TileReference)));
            Assert.That(((TileReference) tile.Value).Name, Is.EqualTo("definition"));
        }
 public void CreatorShouldAssembleDefinitionTileWhenTileIsntAnExistingFileName()
 {
     var entry = new XmlAttributeEntry
                     {
                         Name = "name",
                         Value = "definition",
                     };
     TileAttribute tile = new AutoTileAttributeCreator().Create(entry, _factory);
     Assert.That(tile, Is.Not.Null);
     Assert.That(tile.Name, Is.EqualTo("name"));
     Assert.That(tile.Value, Is.Not.Null);
     Assert.That(tile.Value.GetType(), Is.EqualTo(typeof (TileReference)));
     var reference = (TileReference) tile.Value;
     Assert.That(reference.FallBack, Is.Not.Null);
     Assert.That(reference.Name, Is.EqualTo("definition"));
     Assert.That(((StringTile) reference.FallBack).Value, Is.EqualTo("definition"));
 }
 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 CreatorShouldAssembleTileAttributeWithEmbeddedFileTile()
 {
     var entry = new XmlAttributeEntry
                     {
                         Name = "name",
                         Value = "a.htm",
                         Type = TileType.File.ToString()
                     };
     var factory = new TilesFactory(new MockConfiguration("a.htm", DateTime.Now) {Factory = _locatorFactory });
     var tile = new TemplateTileAttributeCreator().Create(entry, factory);
     Assert.That(tile, Is.Not.Null);
     Assert.That(tile.Name, Is.EqualTo("name"));
     Assert.That(tile.Value, Is.Not.Null);
     Assert.That(tile.Value.GetType(), Is.EqualTo(typeof (TemplateTile)));
     var templateTile = (TemplateTile) tile.Value;
     var template = (FileTemplate) templateTile.Template;
     Assert.That(template.Path.EndsWith("a.htm"));
 }
 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 CreatorShouldAssembleFileTileWhenTileIsFilledWithAnExistingFileName()
 {
     var entry = new XmlAttributeEntry
                     {
                         Name = "name",
                         Value = "a.htm",
                     };
     TileAttribute tile = new AutoTileAttributeCreator().Create(entry, _factory);
     Assert.That(tile, Is.Not.Null);
     Assert.That(tile.Name, Is.EqualTo("name"));
     Assert.That(tile.Value, Is.Not.Null);
     Assert.That(tile.Value.GetType(), Is.EqualTo(typeof (TemplateTile)));
     var templateTile = (TemplateTile) tile.Value;
     var fileTemplate = (FileTemplate) templateTile.Template;
     Assert.That(fileTemplate.Path.EndsWith("a.htm"));
 }