public void CreateShouldReturnMinMaxStatFilterViewModelIfItemStatIsSingleValueItemStat() { var itemStat = new SingleValueItemStat(StatCategory.Explicit); StatFilterViewModel result = this.statFilterViewModelFactory.Create(itemStat, new SearchQueryRequest()); Assert.IsInstanceOf <MinMaxStatFilterViewModel>(result); }
public void CreateShouldTakeMaxValueFromQueryRequestForSingleValueItemStat(decimal?expected) { var itemStat = new SingleValueItemStat(StatCategory.Explicit) { Value = 10 }; this.CreateShouldTakeMaxValueFromQueryRequest(itemStat, expected); }
public void CreateShouldConsiderMaxValuePercentageOffsetForSingleValueItemStat(decimal offset, decimal value, decimal expected) { var itemStat = new SingleValueItemStat(StatCategory.Explicit) { Value = value }; this.CreateShouldConsiderMaxValuePercentageOffsetForItemStat(itemStat, offset, expected); }
public void CreateShouldReturnStatFilterViewModelWithText() { const string expected = "# to Maximum Life"; var itemStat = new SingleValueItemStat(GetItemStat(textWithPlaceholders: expected)); StatFilterViewModel result = this.statFilterViewModelFactory.Create(itemStat, new SearchQueryRequest()); Assert.NotNull(result); Assert.That(result.Text, Is.EqualTo(expected)); }
public void CreateShouldReturnStatFilterViewModelWithCurrentValueForSingleValueItemStat(decimal value, string expected) { var itemStat = new SingleValueItemStat(StatCategory.Explicit) { Value = value }; MinMaxStatFilterViewModel result = this.statFilterViewModelFactory.Create(itemStat, new SearchQueryRequest()) as MinMaxStatFilterViewModel; Assert.NotNull(result); Assert.That(result.Current, Is.EqualTo(expected)); }
public void CreateShouldMapValueOfSingleValueItemStatToMinValue() { const int expected = 2; var itemStat = new SingleValueItemStat(StatCategory.Monster) { Value = expected }; MinMaxStatFilterViewModel result = this.statFilterViewModelFactory.Create(itemStat, new SearchQueryRequest()) as MinMaxStatFilterViewModel; Assert.That(result.Min, Is.EqualTo(expected)); }
public void ParseShouldSetValueOfSingleValueItemStat(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)); SingleValueItemStat itemStat = result.AllStats.First() as SingleValueItemStat; Assert.That(itemStat.Value, Is.EqualTo(expected)); }
public void ParseShouldParseStatWithCorrectCount() { const string statText = "Drops additional Currency Items"; string[] itemStringLines = this.itemStringBuilder .WithType("Oriath's Virtue's Eye") .WithItemLevel(73) .WithItemStat(statText, StatCategory.Monster) .WithItemStat(statText, StatCategory.Monster) .WithItemStat(statText, StatCategory.Monster) .WithDescription(Resources.OrganItemDescriptor) .BuildLines(); ItemStats result = this.organItemStatsParser.Parse(itemStringLines, false); Assert.That(result.AllStats, Has.Count.EqualTo(1)); Assert.That(result.MonsterStats, Has.Count.EqualTo(1)); SingleValueItemStat stat = result.MonsterStats.First() as SingleValueItemStat; Assert.NotNull(stat); Assert.That(stat.Value, Is.EqualTo(3)); }
public void CreateShouldIgnoreConfigurationForMonsterItemStat() { const int expected = 3; var itemStat = new SingleValueItemStat(StatCategory.Monster) { Id = "monsterItemStat", Value = expected }; this.itemSearchOptionsMock.Setup(x => x.CurrentValue) .Returns(new ItemSearchOptions { AdvancedQueryOptions = new AdvancedQueryOptions { MinValuePercentageOffset = -0.1m, MaxValuePercentageOffset = 0.1m } }); MinMaxStatFilterViewModel result = this.statFilterViewModelFactory.Create(itemStat, new SearchQueryRequest()) as MinMaxStatFilterViewModel; Assert.That(result.Min, Is.EqualTo(expected)); Assert.That(result.Max, 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()); }