Exemplo n.º 1
0
        private bool TryGetItemStatForCategoryByMarker(string statText, StatCategory statCategory, out ItemStat itemStat)
        {
            itemStat = null;

            int statCategoryMarkerIndex = statText.IndexOf($"({statCategory.GetDisplayName()})", StringComparison.OrdinalIgnoreCase);

            if (statCategoryMarkerIndex >= 0)
            {
                statText = statText.Substring(0, statCategoryMarkerIndex).Trim();

                itemStat = new ItemStat(statCategory)
                {
                    Text = statText
                };

                return(true);
            }

            return(false);
        }
        public void ParseShouldParseStatTextInCorrectCategory(StatCategory expected, string statText)
        {
            string[] itemStringLines = this.itemStringBuilder
                                       .WithName("Titan Greaves")
                                       .WithItemLevel(75)
                                       .WithItemStat(statText, expected)
                                       .BuildLines();

            this.statsDataServiceMock.Setup(x => x.GetStatData(It.IsAny <string>(), It.IsAny <bool>(), It.IsAny <string[]>()))
            .Returns(new StatData {
                Type = expected.GetDisplayName()
            });

            ItemStats result = this.itemStatsParser.Parse(itemStringLines, false);

            Assert.That(result.AllStats, Has.Count.EqualTo(1));

            ItemStat itemStat = result.AllStats.First();

            Assert.That(itemStat.StatCategory, Is.EqualTo(expected));
        }
        public void ParseShouldCallGetStatDataWithStatCategory(StatCategory statCategory, string statText)
        {
            string[] itemStringLines = this.itemStringBuilder
                                       .WithName("Titan Greaves")
                                       .WithItemLevel(75)
                                       .WithItemStat(statText, statCategory)
                                       .BuildLines();

            this.itemStatsParser.Parse(itemStringLines, false);

            this.statsDataServiceMock.Verify(x => x.GetStatData(It.IsAny <string>(), It.IsAny <bool>(), statCategory.GetDisplayName()));
        }