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);
        }
Beispiel #2
0
        public void CreateShouldAssembleFileTileWithCorrectPath()
        {
            var lib = new TagLib();

            lib.Register(new Tags.Tiles());
            lib.Register(new Sharp());
            var locatorFactory = new FileLocatorFactory().CloneForTagLib(lib) as FileLocatorFactory;
            var factory        = new TilesFactory(new MockConfiguration("x", DateTime.Now)
            {
                Factory = locatorFactory
            });
            var entry = new MockTileEntry
            {
                Name    = "name",
                Path    = "a.htm",
                Extends = null
            };
            var tile = new TemplateTileCreator().Create(entry, factory);

            Assert.That(tile, Is.Not.Null);
            Assert.That(tile.GetType(), Is.EqualTo(typeof(TemplateTile)));
            Assert.That(tile.Name, Is.EqualTo("name"));
            var templateTile = (TemplateTile)tile;
            var fileTemplate = (FileTemplate)templateTile.Template;

            Assert.That(fileTemplate.Path.EndsWith("a.htm"));
        }
Beispiel #3
0
        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 CreateShouldAssembleFileTileWithCorrectExtends()
        {
//            var set = new TilesMap();
//            set.AddTile(new FileTile(
//                            "definition",
//                            "a.htm",
//                            null
//                            )
//                );
            var factory = new TilesFactory(new MockConfiguration());

            var entry = new MockTileEntry
            {
                Name    = "name",
                Path    = null,
                Extends = "definition"
            };
            ITile tile = new DefinitionTileCreator().Create(entry, factory);

            Assert.That(tile, Is.Not.Null);
            Assert.That(tile.GetType(), Is.EqualTo(typeof(DefinitionTile)));
            Assert.That(tile.Name, Is.EqualTo("name"));

            var definition = (DefinitionTile)tile;

            Assert.That(definition.Extends, Is.Not.Null);
            Assert.That(definition.Extends.GetType(), Is.EqualTo(typeof(TileReference)));

            var reference = (TileReference)definition.Extends;

            Assert.That(reference.Name, 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"));
            }
        }
Beispiel #6
0
        public void SetTiles(IConfiguration configuration)
        {
            var newMap = TilesFactory.AssembleFor(configuration).Map;
            var oldMap = Map;

            _map = newMap;
            oldMap.Clear();
        }
Beispiel #7
0
    private void Awake()
    {
        if (Instance)
        {
            Debug.Log("Tiles factory already created");
            return;
        }

        Instance = this;

        foreach (GameObject chuzzlePrefab in ChuzzlePrefabs)
        {
            ChuzzlePool.Instance.RegisterChuzzlePrefab(chuzzlePrefab.GetComponent <Chuzzle>().Color,
                                                       typeof(ColorChuzzle), chuzzlePrefab);
        }

        foreach (GameObject chuzzlePrefab in ChuzzleLockPrefabs)
        {
            ChuzzlePool.Instance.RegisterChuzzlePrefab(chuzzlePrefab.GetComponent <Chuzzle>().Color, typeof(LockChuzzle),
                                                       chuzzlePrefab);
        }

        foreach (GameObject chuzzlePrefab in ChuzzleTwoTimesPrefabs)
        {
            ChuzzlePool.Instance.RegisterChuzzlePrefab(chuzzlePrefab.GetComponent <Chuzzle>().Color,
                                                       typeof(TwoTimeChuzzle), chuzzlePrefab);
        }

        foreach (GameObject chuzzlePrefab in ChuzzleCounterPrefabs)
        {
            ChuzzlePool.Instance.RegisterChuzzlePrefab(chuzzlePrefab.GetComponent <Chuzzle>().Color,
                                                       typeof(CounterChuzzle), chuzzlePrefab);
        }

        foreach (GameObject chuzzlePrefab in HorizontalLineChuzzlePrefabs)
        {
            ChuzzlePool.Instance.RegisterChuzzlePrefab(chuzzlePrefab.GetComponent <Chuzzle>().Color,
                                                       typeof(HorizontalLineChuzzle), chuzzlePrefab);
        }

        foreach (GameObject chuzzlePrefab in VerticalLineChuzzlePrefabs)
        {
            ChuzzlePool.Instance.RegisterChuzzlePrefab(chuzzlePrefab.GetComponent <Chuzzle>().Color,
                                                       typeof(VerticalLineChuzzle), chuzzlePrefab);
        }

        foreach (GameObject chuzzlePrefab in BombChuzzlePrefabs)
        {
            ChuzzlePool.Instance.RegisterChuzzlePrefab(chuzzlePrefab.GetComponent <Chuzzle>().Color, typeof(BombChuzzle),
                                                       chuzzlePrefab);
        }

        ChuzzlePool.Instance.RegisterChuzzlePrefab(InvaderPrefab.GetComponent <Chuzzle>().Color, typeof(InvaderChuzzle),
                                                   InvaderPrefab);
    }
Beispiel #8
0
        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);
        }
        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 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 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 CreateShouldAssembleFileTileWithCorrectExtendsAndPath()
        {
            var lib = new TagLib();

            lib.Register(new Tags.Tiles());
            lib.Register(new Sharp());
            var locatorFactory = new FileLocatorFactory().CloneForTagLib(lib) as FileLocatorFactory;
            var factory        = new TilesFactory(new MockConfiguration("a", DateTime.Now)
            {
                Factory = locatorFactory
            });

            var entry = new MockTileEntry
            {
                Name    = "name",
                Path    = "b.htm",
                Extends = "definition"
            };
            ITile tile = new TemplateOverridingDefinitionTileCreator().Create(entry, factory);

            Assert.That(tile, Is.Not.Null);
            Assert.That(tile.GetType(), Is.EqualTo(typeof(TemplateOveridingDefinitionTile)));
            Assert.That(tile.Name, Is.EqualTo("name"));


            var definition   = (TemplateOveridingDefinitionTile)tile;
            var tileTemplate = (FileTemplate)definition.Template;

            Assert.That(tileTemplate.Path.EndsWith("b.htm"));

            Assert.That(definition.Extends, Is.Not.Null);
            Assert.That(definition.Extends.GetType(), Is.EqualTo(typeof(TileReference)));

            var reference = (TileReference)definition.Extends;

            Assert.That(reference.Name, Is.EqualTo("definition"));
        }
Beispiel #13
0
 public void TearDown()
 {
     _factory = null;
 }