private IEnumerable <DominoTileEntity> GetTiles(DominoTileEntity tile, List <DominoTileEntity> tiles) { tiles.Add(tile); return(tile != tail ? GetTiles(tile.GetLinkedTiles().First(t => !tiles.Contains(t)), tiles) : tiles); }
private IEnumerable <DominoTileEntity> GetTiles(List <DominoTileEntity> list, DominoTileEntity tile) { list.Add(tile); return(tile == engineTile ? list : GetTiles( list, tile.GetLinkedTiles().First()));//TODO: fix hardcoded choise }
public void Link_EngineWithMatching_CorrectLink() { var engine = new DominoTileEntity(12, 12, true); var tile = new DominoTileEntity(12, 11); tile.Link(engine); Assert.Equal(engine, tile.GetLinkedTiles().First()); Assert.Equal("HalfLinkedState", tile.GetStateType().Name); Assert.Equal(1, tile.GetUnlinkedValues().Count()); Assert.Equal(11, tile.GetUnlinkedValues().First()); }
public void Link_TwoMatching_CorrectLink() { var tileOne = new DominoTileEntity(1, 2); var tileTwo = new DominoTileEntity(2, 3); tileTwo.Link(tileOne); Assert.Equal(tileOne, tileTwo.GetLinkedTiles().First()); Assert.Equal("HalfLinkedState", tileTwo.GetStateType().Name); Assert.Equal(1, tileTwo.GetUnlinkedValues().Count()); Assert.Equal(3, tileTwo.GetUnlinkedValues().First()); Assert.Equal(tileTwo, tileOne.GetLinkedTiles().First()); Assert.Equal("HalfLinkedState", tileOne.GetStateType().Name); Assert.Equal(1, tileOne.GetUnlinkedValues().Count()); Assert.Equal(1, tileOne.GetUnlinkedValues().First()); }