public void GetDistributionByEnergyValueTest_CorrectDictionaryIsReturned() { double firstKey = 2500; double secondKey = 10000; double thirdKey = 4500; double forthKey = 12000; double fifthKey = 14000; var expected = new Dictionary <double, int> { [firstKey] = 2, [secondKey] = 2, [thirdKey] = 3, [forthKey] = 1, [fifthKey] = 1 }; var actual = _analyzer.GetDistributionByEnergyValue(); Assert.Equal(expected.Count, actual.Count); Assert.Equal(expected[firstKey], actual[firstKey]); Assert.Equal(expected[secondKey], actual[secondKey]); Assert.Equal(expected[thirdKey], actual[thirdKey]); Assert.Equal(expected[forthKey], actual[forthKey]); Assert.Equal(expected[fifthKey], actual[fifthKey]); }
public async Task <IDictionary <double, int> > GetDistributionByEnergyValueAsync() => await Task.Run(() => _analizer.GetDistributionByEnergyValue());
private static void ShowAnalizerResult(IEnergyObservationAnalizer analizer) { Console.Clear(); Console.WriteLine("Select and press 'Enter' button:"); Console.WriteLine("1 - GetAverageEnergy"); Console.WriteLine("2 - GetDistributionByCoordinates"); Console.WriteLine("3 - GetDistributionByEnergyValue"); Console.WriteLine("4 - GetDistributionByObservationTime"); Console.WriteLine("5 - GetMaxEnergy"); Console.WriteLine("6 - GetMaxEnergyPosition"); Console.WriteLine("7 - GetMaxEnergyTime"); Console.WriteLine("8 - GetMinEnergy"); Console.WriteLine("9 - GetMinEnergyPosition"); Console.WriteLine("10 - GetMinEnergyTime"); Console.WriteLine("something another - exit"); var exit = false; while (!exit) { int menuIndex = 0; var userChoice = Console.ReadLine(); var isParsed = int.TryParse(userChoice, out menuIndex); if (isParsed) { switch (menuIndex) { case 1: Console.WriteLine(" Average energy is: " + analizer.GetAverageEnergy()); break; case 2: Console.WriteLine("Distribution by coordinates is:"); analizer.GetDistributionByCoordinates().PrintDistribution("Coordinates"); break; case 3: Console.WriteLine("Distribution by energy value is:"); analizer.GetDistributionByEnergyValue().PrintDistribution("Energy value"); break; case 4: Console.WriteLine("Distribution by observation time is:"); analizer.GetDistributionByObservationTime().PrintDistribution("Observation time"); break; case 5: Console.WriteLine(" Max energy is: " + analizer.GetMaxEnergy()); break; case 6: Console.WriteLine(" Max energy position is: " + analizer.GetMaxEnergyPosition()); break; case 7: Console.WriteLine(" Max energyTime is: " + analizer.GetMaxEnergyTime()); break; case 8: Console.WriteLine(" Min energy is: " + analizer.GetMinEnergy()); break; case 9: Console.WriteLine(" Position of min energy is: " + analizer.GetMinEnergyPosition()); break; case 10: Console.WriteLine(" Time of min energy is: " + analizer.GetMinEnergyTime()); break; } } else { exit = true; Console.Clear(); ShowMainMenu(); } } }
private static void ProcessAnalyzer(IEnergyObservationAnalizer analizer) { Console.Clear(); Console.WriteLine("Choose method"); Console.WriteLine("1 - GetAverageEnergy"); Console.WriteLine("2 - GetDistributionByCoordinates"); Console.WriteLine("3 - GetDistributionByEnergyValue"); Console.WriteLine("4 - GetDistributionByObservationTime"); Console.WriteLine("5 - GetMaxEnergy"); Console.WriteLine("6 - GetMaxEnergyPosition"); Console.WriteLine("7 - GetMaxEnergyTime"); Console.WriteLine("8 - GetMinEnergy"); Console.WriteLine("9 - GetMinEnergyPosition"); Console.WriteLine("10 - GetMinEnergyTime"); Console.WriteLine("Anything else to exit"); var userChoiceToExit = false; while (!userChoiceToExit) { if (TryReadUserInput(0, 10, out int userChoice)) { switch (userChoice) { case 1: Console.WriteLine(analizer.GetAverageEnergy()); break; case 2: WriteLineDictionary(analizer.GetDistributionByCoordinates()); break; case 3: WriteLineDictionary(analizer.GetDistributionByEnergyValue()); break; case 4: WriteLineDictionary(analizer.GetDistributionByObservationTime()); break; case 5: Console.WriteLine(analizer.GetMaxEnergy()); break; case 6: Console.WriteLine(analizer.GetMaxEnergyPosition()); break; case 7: Console.WriteLine(analizer.GetMaxEnergyTime()); break; case 8: Console.WriteLine(analizer.GetMinEnergy()); break; case 9: Console.WriteLine(analizer.GetMinEnergyPosition()); break; case 10: Console.WriteLine(analizer.GetMinEnergyTime()); break; } } else { userChoiceToExit = true; } } }
public IDictionary <double, int> GetDistributionByEnergyValue() => LoggerHelper.RunWithLogging(_logger, () => _innerAnalyzer.GetDistributionByEnergyValue(), nameof(GetDistributionByEnergyValue));
public IActionResult GetDistributionByEnergyValue() { return(this.Ok(_analyzer.GetDistributionByEnergyValue() .ToDictionary(pair => pair.Key.ToString(CultureInfo.InvariantCulture), pair => pair.Value))); }