public CharacterStatisticsCompareResult CompareCharacterStatistics(List <ProcessedCharacterViewModel> parsedResultList) { List <KeyValuePair <CharacterMainStats, string> > finalResultList = new List <KeyValuePair <CharacterMainStats, string> >(); List <KeyValuePair <int, int> > primaryStatsList = new List <KeyValuePair <int, int> > { new KeyValuePair <int, int>(parsedResultList[0].CharStats.Str, parsedResultList[1].CharStats.Str), new KeyValuePair <int, int>(parsedResultList[0].CharStats.Int, parsedResultList[1].CharStats.Int), new KeyValuePair <int, int>(parsedResultList[0].CharStats.Agi, parsedResultList[1].CharStats.Agi), new KeyValuePair <int, int>(parsedResultList[0].CharStats.Sta, parsedResultList[1].CharStats.Sta) }; if (primaryStatsList.Any(x => x.Key == default(int) || x.Value == default(int))) { return(new CharacterStatisticsCompareResult()); } var countedPrimaryStatsPercent = ComparePrimaryCharacterStats(parsedResultList); List <CharacterMainStats> countedPrimaryStatsPercentKeys = (from list in countedPrimaryStatsPercent select list.Key).ToList(); for (int index = 0; index < countedPrimaryStatsPercent.Count; index++) { string result = primaryStatsList[index].Key > primaryStatsList[index].Value ? MainStatsPercentFormater.AddPlusToPrimaryStatPercent(countedPrimaryStatsPercent[index].Value.ToString()) : MainStatsPercentFormater.AddMinusToPrimaryStatPercent(countedPrimaryStatsPercent[index].Value.ToString()); finalResultList.Add(new KeyValuePair <CharacterMainStats, string>(countedPrimaryStatsPercentKeys[index], result)); } CharacterStatisticsCompareResult characterStatistics = new CharacterStatisticsCompareResult() { CharacterCompareStrDifference = finalResultList[0].Value, CharacterCompareIntDifference = finalResultList[1].Value, CharacterCompareAgiDifference = finalResultList[2].Value, CharacterCompareStaDifference = finalResultList[3].Value }; return(characterStatistics); }
public void PlayerStatisticsComparer_WhenCharacterStatisticAreEquals_ShouldReturnSameValue() { //Arrange CharacterStatisticsCompareResult expected = new CharacterStatisticsCompareResult { CharacterCompareStrDifference = "0%", CharacterCompareIntDifference = "0%", CharacterCompareAgiDifference = "0%", CharacterCompareStaDifference = "0%" }; List <ProcessedCharacterViewModel> processedCharacterViewModel = new List <ProcessedCharacterViewModel>(); //Act { for (int i = 0; i <= 1; i++) { processedCharacterViewModel.Add(new ProcessedCharacterViewModel() { CharStats = new Stats() { Agi = 50, Int = 50, Sta = 50, Str = 50, } }); } } CharacterStatisticsCompareResult result = new StatisticsComparer().CompareCharacterStatistics(processedCharacterViewModel); //Assert Assert.Equal(result.CharacterCompareAgiDifference, expected.CharacterCompareAgiDifference); Assert.Equal(result.CharacterCompareIntDifference, expected.CharacterCompareIntDifference); Assert.Equal(result.CharacterCompareStaDifference, expected.CharacterCompareStaDifference); Assert.Equal(result.CharacterCompareStrDifference, expected.CharacterCompareStrDifference); }