public void CreateShouldReturnMinMaxStatFilterViewModelIfItemStatIsMinMaxValueItemStat() { var itemStat = new MinMaxValueItemStat(StatCategory.Explicit); StatFilterViewModel result = this.statFilterViewModelFactory.Create(itemStat, new SearchQueryRequest()); Assert.IsInstanceOf <MinMaxStatFilterViewModel>(result); }
public void CreateShouldTakeMaxValueFromQueryRequestForMinMaxValueItemStat(decimal?expected) { var itemStat = new MinMaxValueItemStat(StatCategory.Explicit) { MaxValue = 20 }; this.CreateShouldTakeMaxValueFromQueryRequest(itemStat, expected); }
public void CreateShouldConsiderMaxValuePercentageOffsetForMinMaxValueItemStat(decimal offset, decimal maxValue, decimal expected) { var itemStat = new MinMaxValueItemStat(StatCategory.Explicit) { MaxValue = maxValue }; this.CreateShouldConsiderMaxValuePercentageOffsetForItemStat(itemStat, offset, expected); }
public void CreateShouldReturnStatFilterViewModelWithMaxValueForMinMaxValueItemStat(decimal value, decimal expected) { var itemStat = new MinMaxValueItemStat(StatCategory.Explicit) { MaxValue = value }; MinMaxStatFilterViewModel result = this.statFilterViewModelFactory.Create(itemStat, new SearchQueryRequest()) as MinMaxStatFilterViewModel; Assert.NotNull(result); Assert.That(result.Max, Is.EqualTo(expected)); }
public void CreateShouldReturnStatFilterViewModelWithCurrentValueForMinMaxValueItemStat(decimal minValue, decimal maxValue, string expectedMinValue, string expectedMaxValue) { var itemStat = new MinMaxValueItemStat(StatCategory.Explicit) { MinValue = minValue, MaxValue = maxValue }; string expected = $"{expectedMinValue} - {expectedMaxValue}"; MinMaxStatFilterViewModel result = this.statFilterViewModelFactory.Create(itemStat, new SearchQueryRequest()) as MinMaxStatFilterViewModel; Assert.NotNull(result); Assert.That(result.Current, Is.EqualTo(expected)); }
private static ItemStat GetMinMaxValueItemStat(ItemStat itemStat) { var result = new MinMaxValueItemStat(itemStat); int maxValueIndex = itemStat.TextWithPlaceholders.LastIndexOf(Placeholder); if (maxValueIndex >= 0) { result.MaxValue = GetFirstNumericValue(itemStat.Text.Substring(maxValueIndex)).GetValueOrDefault(); } int minValueIndex = GetMinValueIndex(itemStat, maxValueIndex); if (minValueIndex >= 0) { result.MinValue = GetFirstNumericValue(itemStat.Text.Substring(minValueIndex)).GetValueOrDefault(); } return(result); }
public void ParseShouldSetMaxValueOfMinMaxValueItemStat(StatCategory statCategory, string statText, string textWithPlaceholders, int expected) { string[] itemStringLines = this.itemStringBuilder .WithName("Titan Greaves") .WithItemLevel(75) .WithItemStat(statText, statCategory) .BuildLines(); this.statsDataServiceMock.Setup(x => x.GetStatData(It.IsAny <string>(), It.IsAny <bool>(), It.IsAny <string[]>())) .Returns(new StatData { Text = textWithPlaceholders }); ItemStats result = this.itemStatsParser.Parse(itemStringLines, false); Assert.That(result.AllStats, Has.Count.EqualTo(1)); MinMaxValueItemStat itemStat = result.AllStats.First() as MinMaxValueItemStat; Assert.That(itemStat.MaxValue, Is.EqualTo(expected)); }
public void ParseShouldMultipleDifferentStatsCorrectly() { ItemStat expectedExplicitItemStat = new MinMaxValueItemStat(StatCategory.Explicit) { Id = "explicit item stat id", Text = "Minions deal 1 to 15 additional Physical Damage", TextWithPlaceholders = "Minions deal # to # additional Physical Damage", MinValue = 1, MaxValue = 15 }; ItemStat expectedImplicitItemStat = new SingleValueItemStat(StatCategory.Implicit) { Id = "implicit item stat id", Text = "10% increased Movement Speed", TextWithPlaceholders = "#% increased Movement Speed", Value = 10 }; ItemStat expectedCraftedItemStat = new SingleValueItemStat(StatCategory.Crafted) { Id = "crafted item stat id", Text = "+25% to Cold Resistance", TextWithPlaceholders = "#% to Cold Resistance", Value = 25 }; ItemStat expectedEnchantedItemStat = new SingleValueItemStat(StatCategory.Enchant) { Id = "enchanted item stat id", Text = "10% increased Movement Speed if you haven't been Hit Recently", TextWithPlaceholders = "#% increased Movement Speed if you haven't been Hit Recently", Value = 10 }; ItemStat[] itemStats = new[] { expectedExplicitItemStat, expectedImplicitItemStat, expectedCraftedItemStat, expectedEnchantedItemStat }; foreach (var itemStat in itemStats) { this.statsDataServiceMock.Setup(x => x.GetStatData(It.Is <string>(x => x == itemStat.Text), It.IsAny <bool>(), It.IsAny <string[]>())) .Returns(new StatData { Id = itemStat.Id, Text = itemStat.TextWithPlaceholders, Type = itemStat.StatCategory.GetDisplayName() }); } string[] itemStringLines = this.itemStringBuilder .WithName("Titan Greaves") .WithItemLevel(75) .WithItemStat(expectedExplicitItemStat.Text, expectedExplicitItemStat.StatCategory) .WithItemStat($"{expectedImplicitItemStat.Text} ({StatCategory.Implicit.GetDisplayName().ToLower()})", expectedImplicitItemStat.StatCategory) .WithItemStat($"{expectedCraftedItemStat.Text} ({StatCategory.Crafted.GetDisplayName().ToLower()})", expectedCraftedItemStat.StatCategory) .WithItemStat($"{expectedEnchantedItemStat.Text} ({StatCategory.Enchant.GetDisplayName().ToLower()})", expectedEnchantedItemStat.StatCategory) .BuildLines(); ItemStats result = this.itemStatsParser.Parse(itemStringLines, false); Assert.That(result.AllStats, Has.Count.EqualTo(4)); Assert.That(result.ExplicitStats, Has.Count.EqualTo(1)); AssertEquals(expectedExplicitItemStat, result.ExplicitStats.First()); Assert.That(result.ImplicitStats, Has.Count.EqualTo(1)); AssertEquals(expectedImplicitItemStat, result.ImplicitStats.First()); Assert.That(result.CraftedStats, Has.Count.EqualTo(1)); AssertEquals(expectedCraftedItemStat, result.CraftedStats.First()); Assert.That(result.EnchantedStats, Has.Count.EqualTo(1)); AssertEquals(expectedEnchantedItemStat, result.EnchantedStats.First()); }