public void Can_ParseSongDifficultModes(string xPathToSong, string xPathToDifficultMode, int difficultyLevel,
                                                DifficultyCategory difficultyCategory)
        {
            var doc = new HtmlDocument();

            doc.Load("ez2onDBSample.html");
            var            songNode   = doc.DocumentNode.SelectSingleNode(xPathToSong);
            var            mockLogger = new Mock <ILogger <Ez2OnParser> >();
            Ez2OnParser    parser     = new Ez2OnParser(mockLogger.Object);
            DifficultyMode parsedMode =
                parser.ParseDifficultyModeFromSongNode(songNode, xPathToDifficultMode, difficultyCategory);

            Assert.Equal(difficultyLevel, parsedMode.Level);
            Assert.Equal(difficultyCategory, parsedMode.Category);
        }
Beispiel #2
0
        public DifficultyMode ParseDifficultyModeFromSongNode(HtmlNode songNode, string xPathToDifficultyLevel, DifficultyCategory category)
        {
            DifficultyMode difficultyMode     = new DifficultyMode();
            var            difficultLevelNode = songNode.SelectSingleNode(xPathToDifficultyLevel);

            if (difficultLevelNode != null)
            {
                difficultyMode.Level    = int.Parse(difficultLevelNode.InnerText);
                difficultyMode.Category = category;
            }

            if (difficultyMode.Level == 0)
            {
                _logger.LogWarning("Unable to parse DifficultyMode Level. " +
                                   "Consider verifying song difficult level from source");
            }

            return(difficultyMode);
        }